diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ActionsClient.Create.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ActionsClient.Create.g.cs index 997ac1b..1bf965b 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ActionsClient.Create.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ActionsClient.Create.g.cs @@ -14,6 +14,7 @@ public partial class ActionsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -49,6 +50,7 @@ partial void ProcessCreateResponse( /// /// /// + /// 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 CreateAsync( @@ -57,6 +59,7 @@ partial void ProcessCreateResponse( global::LabelStudio.ApiDmActionsCreateRequest request, int? view = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -76,27 +79,48 @@ partial void ProcessCreateResponse( securityRequirements: s_CreateSecurityRequirements, operationName: "CreateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/dm/actions/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddRequiredParameter("id", id.ToValueString()) - .AddRequiredParameter("project", project.ToString()!) - .AddOptionalParameter("view", view?.ToString()) - ; - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/dm/actions/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddRequiredParameter("id", id.ToValueString()) + .AddRequiredParameter("project", project.ToString()!) + .AddOptionalParameter("view", view?.ToString()) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -106,105 +130,264 @@ partial void ProcessCreateResponse( __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); - PrepareCreateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - project: project, - view: view, - 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::LabelStudio.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); + PrepareCreateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + project: project, + view: view, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/dm/actions/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/dm/actions/\"", + 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); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/dm/actions/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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(); + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessCreateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/dm/actions/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/dm/actions/\"", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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(); + } } /// /// Post actions
@@ -222,6 +405,7 @@ partial void ProcessCreateResponse( /// /// Task selection by IDs. If filters are applied, the selection will be applied to the filtered tasks.If "all" is `false`, `"included"` must be used. If "all" is `true`, `"excluded"` must be used.Examples: `{"all": false, "included": [1, 2, 3]}` or `{"all": true, "excluded": [4, 5]}` /// + /// 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 CreateAsync( @@ -231,6 +415,7 @@ partial void ProcessCreateResponse( global::LabelStudio.ApiDmActionsCreateRequestFilters? filters = default, global::System.Collections.Generic.IList? ordering = default, global::LabelStudio.OneOf? selectedItems = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.ApiDmActionsCreateRequest @@ -245,6 +430,7 @@ await CreateAsync( project: project, view: view, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ActionsClient.List.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ActionsClient.List.g.cs index 702f2df..c1b5cf6 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ActionsClient.List.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ActionsClient.List.g.cs @@ -14,6 +14,7 @@ public partial class ActionsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,10 +46,12 @@ partial void ProcessListResponseContent( /// Retrieve all the registered actions with descriptions that data manager can use. ///
/// + /// 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> ListAsync( int project, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -63,25 +66,46 @@ partial void ProcessListResponseContent( securityRequirements: s_ListSecurityRequirements, operationName: "ListAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/dm/actions/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddRequiredParameter("project", project.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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/dm/actions/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddRequiredParameter("project", project.ToString()!) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -91,112 +115,271 @@ partial void ProcessListResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareListRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - project: project); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareListRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + project: project); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessListResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/dm/actions/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/dm/actions/\"", + 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); - ProcessListResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/dm/actions/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessListResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/dm/actions/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/dm/actions/\"", + 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); + ProcessListResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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 + (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.ActionsClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ActionsClient.g.cs index e5ed9fb..62397b7 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ActionsClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ActionsClient.g.cs @@ -30,6 +30,9 @@ public sealed partial class ActionsClient : global::LabelStudio.IActionsClient, #if DEBUG = true; #endif + + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public ActionsClient( 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 ActionsClient. + /// 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 ActionsClient( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::LabelStudio.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::LabelStudio.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ActivityLogsClient.List.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ActivityLogsClient.List.g.cs index 3c49590..60b0051 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ActivityLogsClient.List.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ActivityLogsClient.List.g.cs @@ -14,6 +14,7 @@ public partial class ActivityLogsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -80,6 +81,7 @@ partial void ProcessListResponseContent( /// /// /// + /// 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> ListAsync( @@ -93,6 +95,7 @@ partial void ProcessListResponseContent( string? startDate = default, int? user = default, int? workspace = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -116,34 +119,55 @@ partial void ProcessListResponseContent( securityRequirements: s_ListSecurityRequirements, operationName: "ListAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/activity-logs/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("end_date", endDate) - .AddOptionalParameter("method", method?.ToValueString()) - .AddOptionalParameter("ordering", ordering) - .AddOptionalParameter("page", page?.ToString()) - .AddOptionalParameter("page_size", pageSize?.ToString()) - .AddOptionalParameter("project", project?.ToString()) - .AddOptionalParameter("search", search) - .AddOptionalParameter("start_date", startDate) - .AddOptionalParameter("user", user?.ToString()) - .AddOptionalParameter("workspace", workspace?.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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/activity-logs/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("end_date", endDate) + .AddOptionalParameter("method", method?.ToValueString()) + .AddOptionalParameter("ordering", ordering) + .AddOptionalParameter("page", page?.ToString()) + .AddOptionalParameter("page_size", pageSize?.ToString()) + .AddOptionalParameter("project", project?.ToString()) + .AddOptionalParameter("search", search) + .AddOptionalParameter("start_date", startDate) + .AddOptionalParameter("user", user?.ToString()) + .AddOptionalParameter("workspace", workspace?.ToString()) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -153,154 +177,313 @@ partial void ProcessListResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareListRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - endDate: endDate, - method: method, - ordering: ordering, - page: page, - pageSize: pageSize, - project: project, - search: search, - startDate: startDate, - user: user, - workspace: workspace); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareListRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + endDate: endDate, + method: method, + ordering: ordering, + page: page, + pageSize: pageSize, + project: project, + search: search, + startDate: startDate, + user: user, + workspace: workspace); - 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); - ProcessListResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // - if ((int)__response.StatusCode == 404) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_404 = null; - global::System.Exception? __exception_404 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/activity-logs/\"", + 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) { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/activity-logs/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else + + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/activity-logs/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_404 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::LabelStudio.ApiException( - message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_404, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_404, - 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); - ProcessListResponseContent( + response: __response); + ProcessListResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/activity-logs/\"", + 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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/activity-logs/\"", + 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); + // + 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; + } - return - (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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) - { - } + throw new global::LabelStudio.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), + }; + } + + 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); + ProcessListResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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 + (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.ActivityLogsClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ActivityLogsClient.g.cs index a8bc59b..6e6ea38 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ActivityLogsClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ActivityLogsClient.g.cs @@ -30,6 +30,9 @@ public sealed partial class ActivityLogsClient : global::LabelStudio.IActivityLo #if DEBUG = true; #endif + + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public ActivityLogsClient( 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 ActivityLogsClient. + /// 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 ActivityLogsClient( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::LabelStudio.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::LabelStudio.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/LabelStudio/Generated/LabelStudio.AnalyticsClient.ApiAnalyticsKpisRetrieve.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.AnalyticsClient.ApiAnalyticsKpisRetrieve.g.cs index 6c5c526..61ce281 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.AnalyticsClient.ApiAnalyticsKpisRetrieve.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.AnalyticsClient.ApiAnalyticsKpisRetrieve.g.cs @@ -14,6 +14,7 @@ public partial class AnalyticsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -42,9 +43,11 @@ partial void ProcessApiAnalyticsKpisRetrieveResponseContent( /// List all available KPIs
/// Returns metadata for all available KPI (Key Performance Indicator) classes. Each KPI includes its key, label, base class, dependencies, and configuration. This endpoint is useful for discovering available metrics and understanding their relationships and requirements. /// + /// 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> ApiAnalyticsKpisRetrieveAsync( + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -58,22 +61,43 @@ partial void ProcessApiAnalyticsKpisRetrieveResponseContent( securityRequirements: s_ApiAnalyticsKpisRetrieveSecurityRequirements, operationName: "ApiAnalyticsKpisRetrieveAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/analytics/kpis/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/analytics/kpis/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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 ProcessApiAnalyticsKpisRetrieveResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareApiAnalyticsKpisRetrieveRequest( - 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); + PrepareApiAnalyticsKpisRetrieveRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiAnalyticsKpisRetrieveResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiAnalyticsKpisRetrieve", + methodName: "ApiAnalyticsKpisRetrieveAsync", + pathTemplate: "\"/api/analytics/kpis/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiAnalyticsKpisRetrieve", + methodName: "ApiAnalyticsKpisRetrieveAsync", + pathTemplate: "\"/api/analytics/kpis/\"", + 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); - ProcessApiAnalyticsKpisRetrieveResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiAnalyticsKpisRetrieve", + methodName: "ApiAnalyticsKpisRetrieveAsync", + pathTemplate: "\"/api/analytics/kpis/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessApiAnalyticsKpisRetrieveResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiAnalyticsKpisRetrieve", + methodName: "ApiAnalyticsKpisRetrieveAsync", + pathTemplate: "\"/api/analytics/kpis/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiAnalyticsKpisRetrieve", + methodName: "ApiAnalyticsKpisRetrieveAsync", + pathTemplate: "\"/api/analytics/kpis/\"", + 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); + ProcessApiAnalyticsKpisRetrieveResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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 + (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.AnalyticsClient.ApiAnalyticsKpisRetrieve2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.AnalyticsClient.ApiAnalyticsKpisRetrieve2.g.cs index 3e97dee..7b7ed60 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.AnalyticsClient.ApiAnalyticsKpisRetrieve2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.AnalyticsClient.ApiAnalyticsKpisRetrieve2.g.cs @@ -14,6 +14,7 @@ public partial class AnalyticsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -69,6 +70,7 @@ partial void ProcessApiAnalyticsKpisRetrieve2ResponseContent( /// /// /// + /// 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 ApiAnalyticsKpisRetrieve2Async( @@ -81,6 +83,7 @@ partial void ProcessApiAnalyticsKpisRetrieve2ResponseContent( string? segmentByTime = default, bool? segmentByUser = default, global::System.DateTime? start = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -103,32 +106,53 @@ partial void ProcessApiAnalyticsKpisRetrieve2ResponseContent( securityRequirements: s_ApiAnalyticsKpisRetrieve2SecurityRequirements, operationName: "ApiAnalyticsKpisRetrieve2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/analytics/kpis/{kpiKey}", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("end", end?.ToString("yyyy-MM-ddTHH:mm:ssZ")) - .AddOptionalParameter("members", members) - .AddOptionalParameter("projects", projects) - .AddOptionalParameter("segment_by_project", segmentByProject?.ToString().ToLowerInvariant()) - .AddOptionalParameter("segment_by_time", segmentByTime) - .AddOptionalParameter("segment_by_user", segmentByUser?.ToString().ToLowerInvariant()) - .AddOptionalParameter("start", start?.ToString("yyyy-MM-ddTHH:mm:ssZ")) - .AddRequiredParameter("tz", tz) - ; - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/analytics/kpis/{kpiKey}", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("end", end?.ToString("yyyy-MM-ddTHH:mm:ssZ")) + .AddOptionalParameter("members", members) + .AddOptionalParameter("projects", projects) + .AddOptionalParameter("segment_by_project", segmentByProject?.ToString().ToLowerInvariant()) + .AddOptionalParameter("segment_by_time", segmentByTime) + .AddOptionalParameter("segment_by_user", segmentByUser?.ToString().ToLowerInvariant()) + .AddOptionalParameter("start", start?.ToString("yyyy-MM-ddTHH:mm:ssZ")) + .AddRequiredParameter("tz", tz) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -138,186 +162,345 @@ partial void ProcessApiAnalyticsKpisRetrieve2ResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareApiAnalyticsKpisRetrieve2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - end: end, - kpiKey: kpiKey, - members: members, - projects: projects, - segmentByProject: segmentByProject, - segmentByTime: segmentByTime, - segmentByUser: segmentByUser, - start: start, - tz: tz); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareApiAnalyticsKpisRetrieve2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + end: end, + kpiKey: kpiKey, + members: members, + projects: projects, + segmentByProject: segmentByProject, + segmentByTime: segmentByTime, + segmentByUser: segmentByUser, + start: start, + tz: tz); - 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); - ProcessApiAnalyticsKpisRetrieve2Response( - httpClient: HttpClient, - httpResponseMessage: __response); - // - if ((int)__response.StatusCode == 400) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_400 = null; - global::System.Exception? __exception_400 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiAnalyticsKpisRetrieve2", + methodName: "ApiAnalyticsKpisRetrieve2Async", + pathTemplate: "$\"/api/analytics/kpis/{kpiKey}\"", + 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_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + __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_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - } - } - catch (global::System.Exception __ex) - { - __exception_400 = __ex; - } + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiAnalyticsKpisRetrieve2", + methodName: "ApiAnalyticsKpisRetrieve2Async", + pathTemplate: "$\"/api/analytics/kpis/{kpiKey}\"", + 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; + } - throw new global::LabelStudio.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 (ReadResponseAsString) - { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else + + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiAnalyticsKpisRetrieve2", + methodName: "ApiAnalyticsKpisRetrieve2Async", + pathTemplate: "$\"/api/analytics/kpis/{kpiKey}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_404 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::LabelStudio.ApiException( - message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_404, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_404, - 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); - ProcessApiAnalyticsKpisRetrieve2ResponseContent( + response: __response); + ProcessApiAnalyticsKpisRetrieve2Response( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::LabelStudio.KPIDetailResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiAnalyticsKpisRetrieve2", + methodName: "ApiAnalyticsKpisRetrieve2Async", + pathTemplate: "$\"/api/analytics/kpis/{kpiKey}\"", + 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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiAnalyticsKpisRetrieve2", + methodName: "ApiAnalyticsKpisRetrieve2Async", + pathTemplate: "$\"/api/analytics/kpis/{kpiKey}\"", + 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); + // + 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; + } - return - await global::LabelStudio.KPIDetailResponse.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) - { - } + throw new global::LabelStudio.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; + } + + throw new global::LabelStudio.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), + }; + } + + 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); + ProcessApiAnalyticsKpisRetrieve2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.KPIDetailResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.KPIDetailResponse.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.AnalyticsClient.ApiAnalyticsViewsCreate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.AnalyticsClient.ApiAnalyticsViewsCreate.g.cs index ff7ca5c..46c1217 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.AnalyticsClient.ApiAnalyticsViewsCreate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.AnalyticsClient.ApiAnalyticsViewsCreate.g.cs @@ -14,6 +14,7 @@ public partial class AnalyticsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -55,11 +56,13 @@ partial void ProcessApiAnalyticsViewsCreateResponseContent( /// * update / destroy — owner-only /// /// + /// 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 ApiAnalyticsViewsCreateAsync( global::LabelStudio.AnalyticsViewRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -76,22 +79,43 @@ partial void ProcessApiAnalyticsViewsCreateResponseContent( securityRequirements: s_ApiAnalyticsViewsCreateSecurityRequirements, operationName: "ApiAnalyticsViewsCreateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/analytics/views/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/analytics/views/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -101,118 +125,277 @@ partial void ProcessApiAnalyticsViewsCreateResponseContent( __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::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareApiAnalyticsViewsCreateRequest( - 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); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareApiAnalyticsViewsCreateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiAnalyticsViewsCreateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiAnalyticsViewsCreate", + methodName: "ApiAnalyticsViewsCreateAsync", + pathTemplate: "\"/api/analytics/views/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiAnalyticsViewsCreate", + methodName: "ApiAnalyticsViewsCreateAsync", + pathTemplate: "\"/api/analytics/views/\"", + 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); - ProcessApiAnalyticsViewsCreateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiAnalyticsViewsCreate", + methodName: "ApiAnalyticsViewsCreateAsync", + pathTemplate: "\"/api/analytics/views/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.AnalyticsView.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.AnalyticsView.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessApiAnalyticsViewsCreateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiAnalyticsViewsCreate", + methodName: "ApiAnalyticsViewsCreateAsync", + pathTemplate: "\"/api/analytics/views/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiAnalyticsViewsCreate", + methodName: "ApiAnalyticsViewsCreateAsync", + pathTemplate: "\"/api/analytics/views/\"", + 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); + ProcessApiAnalyticsViewsCreateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.AnalyticsView.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.AnalyticsView.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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(); + } } /// /// CRUD endpoints for per-user analytics saved views.
@@ -234,12 +417,14 @@ partial void ProcessApiAnalyticsViewsCreateResponseContent( /// /// /// + /// 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 ApiAnalyticsViewsCreateAsync( string name, global::LabelStudio.DashboardTypeEnum? dashboardType = default, object? filters = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.AnalyticsViewRequest @@ -251,6 +436,7 @@ partial void ProcessApiAnalyticsViewsCreateResponseContent( return await ApiAnalyticsViewsCreateAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.AnalyticsClient.ApiAnalyticsViewsDestroy.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.AnalyticsClient.ApiAnalyticsViewsDestroy.g.cs index 2ed99cb..e63611f 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.AnalyticsClient.ApiAnalyticsViewsDestroy.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.AnalyticsClient.ApiAnalyticsViewsDestroy.g.cs @@ -14,6 +14,7 @@ public partial class AnalyticsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -50,10 +51,12 @@ partial void ProcessApiAnalyticsViewsDestroyResponse( /// * update / destroy — owner-only ///
/// + /// 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 ApiAnalyticsViewsDestroyAsync( global::System.Guid uuid, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -68,22 +71,43 @@ partial void ProcessApiAnalyticsViewsDestroyResponse( securityRequirements: s_ApiAnalyticsViewsDestroySecurityRequirements, operationName: "ApiAnalyticsViewsDestroyAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/analytics/views/{uuid}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/analytics/views/{uuid}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -93,96 +117,255 @@ partial void ProcessApiAnalyticsViewsDestroyResponse( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareApiAnalyticsViewsDestroyRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - uuid: uuid); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareApiAnalyticsViewsDestroyRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + uuid: uuid); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiAnalyticsViewsDestroy", + methodName: "ApiAnalyticsViewsDestroyAsync", + pathTemplate: "$\"/api/analytics/views/{uuid}/\"", + 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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiAnalyticsViewsDestroy", + methodName: "ApiAnalyticsViewsDestroyAsync", + pathTemplate: "$\"/api/analytics/views/{uuid}/\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiAnalyticsViewsDestroyResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiAnalyticsViewsDestroy", + methodName: "ApiAnalyticsViewsDestroyAsync", + pathTemplate: "$\"/api/analytics/views/{uuid}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessApiAnalyticsViewsDestroyResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiAnalyticsViewsDestroy", + methodName: "ApiAnalyticsViewsDestroyAsync", + pathTemplate: "$\"/api/analytics/views/{uuid}/\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiAnalyticsViewsDestroy", + methodName: "ApiAnalyticsViewsDestroyAsync", + pathTemplate: "$\"/api/analytics/views/{uuid}/\"", + httpMethod: "DELETE", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.AnalyticsClient.ApiAnalyticsViewsList.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.AnalyticsClient.ApiAnalyticsViewsList.g.cs index 7a80680..0dfbd93 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.AnalyticsClient.ApiAnalyticsViewsList.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.AnalyticsClient.ApiAnalyticsViewsList.g.cs @@ -14,6 +14,7 @@ public partial class AnalyticsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -55,10 +56,12 @@ partial void ProcessApiAnalyticsViewsListResponseContent( /// * update / destroy — owner-only /// /// + /// 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> ApiAnalyticsViewsListAsync( string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -73,25 +76,46 @@ partial void ProcessApiAnalyticsViewsListResponseContent( securityRequirements: s_ApiAnalyticsViewsListSecurityRequirements, operationName: "ApiAnalyticsViewsListAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/analytics/views/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("ordering", ordering) - ; - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/analytics/views/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("ordering", ordering) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -101,112 +125,271 @@ partial void ProcessApiAnalyticsViewsListResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareApiAnalyticsViewsListRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - ordering: ordering); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareApiAnalyticsViewsListRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + ordering: ordering); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiAnalyticsViewsListResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiAnalyticsViewsList", + methodName: "ApiAnalyticsViewsListAsync", + pathTemplate: "\"/api/analytics/views/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiAnalyticsViewsList", + methodName: "ApiAnalyticsViewsListAsync", + pathTemplate: "\"/api/analytics/views/\"", + 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); - ProcessApiAnalyticsViewsListResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiAnalyticsViewsList", + methodName: "ApiAnalyticsViewsListAsync", + pathTemplate: "\"/api/analytics/views/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessApiAnalyticsViewsListResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiAnalyticsViewsList", + methodName: "ApiAnalyticsViewsListAsync", + pathTemplate: "\"/api/analytics/views/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiAnalyticsViewsList", + methodName: "ApiAnalyticsViewsListAsync", + pathTemplate: "\"/api/analytics/views/\"", + 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); + ProcessApiAnalyticsViewsListResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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 + (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.AnalyticsClient.ApiAnalyticsViewsPartialUpdate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.AnalyticsClient.ApiAnalyticsViewsPartialUpdate.g.cs index 3cb2169..42767b4 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.AnalyticsClient.ApiAnalyticsViewsPartialUpdate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.AnalyticsClient.ApiAnalyticsViewsPartialUpdate.g.cs @@ -14,6 +14,7 @@ public partial class AnalyticsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -58,12 +59,14 @@ partial void ProcessApiAnalyticsViewsPartialUpdateResponseContent( /// /// /// + /// 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 ApiAnalyticsViewsPartialUpdateAsync( global::System.Guid uuid, global::LabelStudio.PatchedAnalyticsViewRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -81,22 +84,43 @@ partial void ProcessApiAnalyticsViewsPartialUpdateResponseContent( securityRequirements: s_ApiAnalyticsViewsPartialUpdateSecurityRequirements, operationName: "ApiAnalyticsViewsPartialUpdateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/analytics/views/{uuid}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/analytics/views/{uuid}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -106,119 +130,278 @@ partial void ProcessApiAnalyticsViewsPartialUpdateResponseContent( __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); - PrepareApiAnalyticsViewsPartialUpdateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - uuid: uuid, - 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::LabelStudio.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); + PrepareApiAnalyticsViewsPartialUpdateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + uuid: uuid, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiAnalyticsViewsPartialUpdateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiAnalyticsViewsPartialUpdate", + methodName: "ApiAnalyticsViewsPartialUpdateAsync", + pathTemplate: "$\"/api/analytics/views/{uuid}/\"", + 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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiAnalyticsViewsPartialUpdate", + methodName: "ApiAnalyticsViewsPartialUpdateAsync", + pathTemplate: "$\"/api/analytics/views/{uuid}/\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessApiAnalyticsViewsPartialUpdateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiAnalyticsViewsPartialUpdate", + methodName: "ApiAnalyticsViewsPartialUpdateAsync", + pathTemplate: "$\"/api/analytics/views/{uuid}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.AnalyticsView.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.AnalyticsView.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessApiAnalyticsViewsPartialUpdateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiAnalyticsViewsPartialUpdate", + methodName: "ApiAnalyticsViewsPartialUpdateAsync", + pathTemplate: "$\"/api/analytics/views/{uuid}/\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiAnalyticsViewsPartialUpdate", + methodName: "ApiAnalyticsViewsPartialUpdateAsync", + pathTemplate: "$\"/api/analytics/views/{uuid}/\"", + httpMethod: "PATCH", + 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); + ProcessApiAnalyticsViewsPartialUpdateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.AnalyticsView.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.AnalyticsView.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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(); + } } /// /// CRUD endpoints for per-user analytics saved views.
@@ -241,6 +424,7 @@ partial void ProcessApiAnalyticsViewsPartialUpdateResponseContent( /// /// /// + /// 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 ApiAnalyticsViewsPartialUpdateAsync( @@ -248,6 +432,7 @@ partial void ProcessApiAnalyticsViewsPartialUpdateResponseContent( global::LabelStudio.DashboardTypeEnum? dashboardType = default, object? filters = default, string? name = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.PatchedAnalyticsViewRequest @@ -260,6 +445,7 @@ partial void ProcessApiAnalyticsViewsPartialUpdateResponseContent( return await ApiAnalyticsViewsPartialUpdateAsync( uuid: uuid, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.AnalyticsClient.ApiAnalyticsViewsRetrieve.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.AnalyticsClient.ApiAnalyticsViewsRetrieve.g.cs index 55c413b..59fc2b5 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.AnalyticsClient.ApiAnalyticsViewsRetrieve.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.AnalyticsClient.ApiAnalyticsViewsRetrieve.g.cs @@ -14,6 +14,7 @@ public partial class AnalyticsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -55,10 +56,12 @@ partial void ProcessApiAnalyticsViewsRetrieveResponseContent( /// * update / destroy — owner-only ///
/// + /// 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 ApiAnalyticsViewsRetrieveAsync( global::System.Guid uuid, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -73,22 +76,43 @@ partial void ProcessApiAnalyticsViewsRetrieveResponseContent( securityRequirements: s_ApiAnalyticsViewsRetrieveSecurityRequirements, operationName: "ApiAnalyticsViewsRetrieveAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/analytics/views/{uuid}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/analytics/views/{uuid}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -98,112 +122,271 @@ partial void ProcessApiAnalyticsViewsRetrieveResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareApiAnalyticsViewsRetrieveRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - uuid: uuid); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareApiAnalyticsViewsRetrieveRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + uuid: uuid); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiAnalyticsViewsRetrieveResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiAnalyticsViewsRetrieve", + methodName: "ApiAnalyticsViewsRetrieveAsync", + pathTemplate: "$\"/api/analytics/views/{uuid}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiAnalyticsViewsRetrieve", + methodName: "ApiAnalyticsViewsRetrieveAsync", + pathTemplate: "$\"/api/analytics/views/{uuid}/\"", + 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); - ProcessApiAnalyticsViewsRetrieveResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiAnalyticsViewsRetrieve", + methodName: "ApiAnalyticsViewsRetrieveAsync", + pathTemplate: "$\"/api/analytics/views/{uuid}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.AnalyticsView.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.AnalyticsView.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessApiAnalyticsViewsRetrieveResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiAnalyticsViewsRetrieve", + methodName: "ApiAnalyticsViewsRetrieveAsync", + pathTemplate: "$\"/api/analytics/views/{uuid}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiAnalyticsViewsRetrieve", + methodName: "ApiAnalyticsViewsRetrieveAsync", + pathTemplate: "$\"/api/analytics/views/{uuid}/\"", + 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); + ProcessApiAnalyticsViewsRetrieveResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.AnalyticsView.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.AnalyticsView.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.AnalyticsClient.ApiAnalyticsViewsUpdate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.AnalyticsClient.ApiAnalyticsViewsUpdate.g.cs index 0b80cb5..d3a6338 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.AnalyticsClient.ApiAnalyticsViewsUpdate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.AnalyticsClient.ApiAnalyticsViewsUpdate.g.cs @@ -14,6 +14,7 @@ public partial class AnalyticsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -58,12 +59,14 @@ partial void ProcessApiAnalyticsViewsUpdateResponseContent( /// /// /// + /// 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 ApiAnalyticsViewsUpdateAsync( global::System.Guid uuid, global::LabelStudio.AnalyticsViewRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -81,22 +84,43 @@ partial void ProcessApiAnalyticsViewsUpdateResponseContent( securityRequirements: s_ApiAnalyticsViewsUpdateSecurityRequirements, operationName: "ApiAnalyticsViewsUpdateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/analytics/views/{uuid}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/analytics/views/{uuid}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -106,119 +130,278 @@ partial void ProcessApiAnalyticsViewsUpdateResponseContent( __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); - PrepareApiAnalyticsViewsUpdateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - uuid: uuid, - 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::LabelStudio.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); + PrepareApiAnalyticsViewsUpdateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + uuid: uuid, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiAnalyticsViewsUpdateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiAnalyticsViewsUpdate", + methodName: "ApiAnalyticsViewsUpdateAsync", + pathTemplate: "$\"/api/analytics/views/{uuid}/\"", + 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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiAnalyticsViewsUpdate", + methodName: "ApiAnalyticsViewsUpdateAsync", + pathTemplate: "$\"/api/analytics/views/{uuid}/\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessApiAnalyticsViewsUpdateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiAnalyticsViewsUpdate", + methodName: "ApiAnalyticsViewsUpdateAsync", + pathTemplate: "$\"/api/analytics/views/{uuid}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.AnalyticsView.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.AnalyticsView.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessApiAnalyticsViewsUpdateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiAnalyticsViewsUpdate", + methodName: "ApiAnalyticsViewsUpdateAsync", + pathTemplate: "$\"/api/analytics/views/{uuid}/\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiAnalyticsViewsUpdate", + methodName: "ApiAnalyticsViewsUpdateAsync", + pathTemplate: "$\"/api/analytics/views/{uuid}/\"", + httpMethod: "PUT", + 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); + ProcessApiAnalyticsViewsUpdateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.AnalyticsView.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.AnalyticsView.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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(); + } } /// /// CRUD endpoints for per-user analytics saved views.
@@ -241,6 +424,7 @@ partial void ProcessApiAnalyticsViewsUpdateResponseContent( /// /// /// + /// 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 ApiAnalyticsViewsUpdateAsync( @@ -248,6 +432,7 @@ partial void ProcessApiAnalyticsViewsUpdateResponseContent( string name, global::LabelStudio.DashboardTypeEnum? dashboardType = default, object? filters = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.AnalyticsViewRequest @@ -260,6 +445,7 @@ partial void ProcessApiAnalyticsViewsUpdateResponseContent( return await ApiAnalyticsViewsUpdateAsync( uuid: uuid, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.AnalyticsClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.AnalyticsClient.g.cs index 3db4060..b0529c8 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.AnalyticsClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.AnalyticsClient.g.cs @@ -30,6 +30,9 @@ public sealed partial class AnalyticsClient : global::LabelStudio.IAnalyticsClie #if DEBUG = true; #endif + + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public AnalyticsClient( 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 AnalyticsClient. + /// 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 AnalyticsClient( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::LabelStudio.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::LabelStudio.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/LabelStudio/Generated/LabelStudio.AnnotationHistoryClient.Delete.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.AnnotationHistoryClient.Delete.g.cs index ae2d156..4cc478c 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.AnnotationHistoryClient.Delete.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.AnnotationHistoryClient.Delete.g.cs @@ -14,6 +14,7 @@ public partial class AnnotationHistoryClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -57,12 +58,14 @@ partial void ProcessDeleteResponseContent( /// /// /// + /// 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 DeleteAsync( int? annotation = default, int? project = default, int? task = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -79,27 +82,48 @@ partial void ProcessDeleteResponseContent( securityRequirements: s_DeleteSecurityRequirements, operationName: "DeleteAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/annotation-history/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("annotation", annotation?.ToString()) - .AddOptionalParameter("project", project?.ToString()) - .AddOptionalParameter("task", task?.ToString()) - ; - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/annotation-history/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("annotation", annotation?.ToString()) + .AddOptionalParameter("project", project?.ToString()) + .AddOptionalParameter("task", task?.ToString()) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -109,114 +133,273 @@ partial void ProcessDeleteResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDeleteRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - annotation: annotation, - project: project, - task: task); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDeleteRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + annotation: annotation, + project: project, + task: task); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessDeleteResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "\"/api/annotation-history/\"", + 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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "\"/api/annotation-history/\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessDeleteResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "\"/api/annotation-history/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.ApiAnnotationHistoryDestroyResponse.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.ApiAnnotationHistoryDestroyResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessDeleteResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "\"/api/annotation-history/\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "\"/api/annotation-history/\"", + httpMethod: "DELETE", + 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); + ProcessDeleteResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.ApiAnnotationHistoryDestroyResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiAnnotationHistoryDestroyResponse.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.AnnotationHistoryClient.List.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.AnnotationHistoryClient.List.g.cs index 605345d..5a1cfe9 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.AnnotationHistoryClient.List.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.AnnotationHistoryClient.List.g.cs @@ -14,6 +14,7 @@ public partial class AnnotationHistoryClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -54,11 +55,13 @@ partial void ProcessListResponseContent( ///
/// /// + /// 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> ListAsync( int? annotation = default, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -74,26 +77,47 @@ partial void ProcessListResponseContent( securityRequirements: s_ListSecurityRequirements, operationName: "ListAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/annotation-history/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("annotation", annotation?.ToString()) - .AddOptionalParameter("ordering", ordering) - ; - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/annotation-history/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("annotation", annotation?.ToString()) + .AddOptionalParameter("ordering", ordering) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -103,113 +127,272 @@ partial void ProcessListResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareListRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - annotation: annotation, - ordering: ordering); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareListRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + annotation: annotation, + ordering: ordering); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessListResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/annotation-history/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/annotation-history/\"", + 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); - ProcessListResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/annotation-history/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessListResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/annotation-history/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/annotation-history/\"", + 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); + ProcessListResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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 + (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.AnnotationHistoryClient.ListForProject.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.AnnotationHistoryClient.ListForProject.g.cs index b181b5e..2859ea0 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.AnnotationHistoryClient.ListForProject.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.AnnotationHistoryClient.ListForProject.g.cs @@ -14,6 +14,7 @@ public partial class AnnotationHistoryClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -57,12 +58,14 @@ partial void ProcessListForProjectResponseContent( /// /// /// + /// 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 ListForProjectAsync( int id, int? page = default, int? pageSize = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -79,26 +82,47 @@ partial void ProcessListForProjectResponseContent( securityRequirements: s_ListForProjectSecurityRequirements, operationName: "ListForProjectAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{id}/annotation-history/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("page", page?.ToString()) - .AddOptionalParameter("page_size", pageSize?.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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{id}/annotation-history/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("page", page?.ToString()) + .AddOptionalParameter("page_size", pageSize?.ToString()) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -108,114 +132,273 @@ partial void ProcessListForProjectResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareListForProjectRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - page: page, - pageSize: pageSize); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareListForProjectRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + page: page, + pageSize: pageSize); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessListForProjectResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListForProject", + methodName: "ListForProjectAsync", + pathTemplate: "$\"/api/projects/{id}/annotation-history/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListForProject", + methodName: "ListForProjectAsync", + pathTemplate: "$\"/api/projects/{id}/annotation-history/\"", + 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); - ProcessListForProjectResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListForProject", + methodName: "ListForProjectAsync", + pathTemplate: "$\"/api/projects/{id}/annotation-history/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.PaginatedAnnotationHistoryList.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.PaginatedAnnotationHistoryList.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessListForProjectResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListForProject", + methodName: "ListForProjectAsync", + pathTemplate: "$\"/api/projects/{id}/annotation-history/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListForProject", + methodName: "ListForProjectAsync", + pathTemplate: "$\"/api/projects/{id}/annotation-history/\"", + 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); + ProcessListForProjectResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.PaginatedAnnotationHistoryList.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.PaginatedAnnotationHistoryList.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.AnnotationHistoryClient.Retrieve.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.AnnotationHistoryClient.Retrieve.g.cs index c748eb6..8765823 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.AnnotationHistoryClient.Retrieve.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.AnnotationHistoryClient.Retrieve.g.cs @@ -14,6 +14,7 @@ public partial class AnnotationHistoryClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,10 +52,12 @@ partial void ProcessRetrieveResponseContent( /// Get one annotation history item by ID with full result. Used when FIT-720 lazy load is on and the user clicks a stubbed history item to hydrate it. /// /// + /// 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 RetrieveAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -69,22 +72,43 @@ partial void ProcessRetrieveResponseContent( securityRequirements: s_RetrieveSecurityRequirements, operationName: "RetrieveAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/annotation-history/{id}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/annotation-history/{id}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,112 +118,271 @@ partial void ProcessRetrieveResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareRetrieveRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareRetrieveRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessRetrieveResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Retrieve", + methodName: "RetrieveAsync", + pathTemplate: "$\"/api/annotation-history/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Retrieve", + methodName: "RetrieveAsync", + pathTemplate: "$\"/api/annotation-history/{id}/\"", + 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); - ProcessRetrieveResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Retrieve", + methodName: "RetrieveAsync", + pathTemplate: "$\"/api/annotation-history/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.AnnotationHistory.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.AnnotationHistory.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessRetrieveResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Retrieve", + methodName: "RetrieveAsync", + pathTemplate: "$\"/api/annotation-history/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Retrieve", + methodName: "RetrieveAsync", + pathTemplate: "$\"/api/annotation-history/{id}/\"", + 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); + ProcessRetrieveResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.AnnotationHistory.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.AnnotationHistory.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.AnnotationHistoryClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.AnnotationHistoryClient.g.cs index 9c8c7dc..6c85a3a 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.AnnotationHistoryClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.AnnotationHistoryClient.g.cs @@ -30,6 +30,9 @@ public sealed partial class AnnotationHistoryClient : global::LabelStudio.IAnnot #if DEBUG = true; #endif + + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public AnnotationHistoryClient( 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 AnnotationHistoryClient. + /// 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 AnnotationHistoryClient( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::LabelStudio.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::LabelStudio.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/LabelStudio/Generated/LabelStudio.AnnotationReviews2Client.Create.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.AnnotationReviews2Client.Create.g.cs index 826fec8..4b5626c 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.AnnotationReviews2Client.Create.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.AnnotationReviews2Client.Create.g.cs @@ -14,6 +14,7 @@ public partial class AnnotationReviews2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -54,12 +55,14 @@ partial void ProcessCreateResponseContent( /// /// /// + /// 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 CreateAsync( global::LabelStudio.AnnotationReviewRequest request, bool? asyncPostprocess = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -77,25 +80,46 @@ partial void ProcessCreateResponseContent( securityRequirements: s_CreateSecurityRequirements, operationName: "CreateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/annotation-reviews/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("async_postprocess", asyncPostprocess?.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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/annotation-reviews/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("async_postprocess", asyncPostprocess?.ToString().ToLowerInvariant()) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,119 +129,278 @@ partial void ProcessCreateResponseContent( __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); - PrepareCreateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - asyncPostprocess: asyncPostprocess, - 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::LabelStudio.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); + PrepareCreateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + asyncPostprocess: asyncPostprocess, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/annotation-reviews/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/annotation-reviews/\"", + 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); - ProcessCreateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/annotation-reviews/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.AnnotationReview.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.AnnotationReview.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessCreateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/annotation-reviews/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/annotation-reviews/\"", + 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); + ProcessCreateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.AnnotationReview.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.AnnotationReview.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 review
@@ -243,6 +426,7 @@ partial void ProcessCreateResponseContent( /// /// /// + /// 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 CreateAsync( @@ -254,6 +438,7 @@ partial void ProcessCreateResponseContent( bool? removeFromQueue = default, object? result = default, global::System.DateTime? startedAt = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.AnnotationReviewRequest @@ -270,6 +455,7 @@ partial void ProcessCreateResponseContent( return await CreateAsync( asyncPostprocess: asyncPostprocess, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.AnnotationReviews2Client.Delete.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.AnnotationReviews2Client.Delete.g.cs index 577ef27..8e5baba 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.AnnotationReviews2Client.Delete.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.AnnotationReviews2Client.Delete.g.cs @@ -14,6 +14,7 @@ public partial class AnnotationReviews2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -46,10 +47,12 @@ partial void ProcessDeleteResponse( /// Delete a review by ID. Only allowed for organizations with reviewing features enabled. ///
/// + /// 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 DeleteAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -64,22 +67,43 @@ partial void ProcessDeleteResponse( securityRequirements: s_DeleteSecurityRequirements, operationName: "DeleteAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/annotation-reviews/{id}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/annotation-reviews/{id}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -89,96 +113,255 @@ partial void ProcessDeleteResponse( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDeleteRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDeleteRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/annotation-reviews/{id}/\"", + 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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/annotation-reviews/{id}/\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessDeleteResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/annotation-reviews/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessDeleteResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/annotation-reviews/{id}/\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/annotation-reviews/{id}/\"", + httpMethod: "DELETE", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.AnnotationReviews2Client.Get.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.AnnotationReviews2Client.Get.g.cs index 5f0c281..0ef0760 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.AnnotationReviews2Client.Get.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.AnnotationReviews2Client.Get.g.cs @@ -14,6 +14,7 @@ public partial class AnnotationReviews2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,10 +52,12 @@ partial void ProcessGetResponseContent( /// Retrieve a specific review by ID for an annotation. Only allowed for organizations with reviewing features enabled. /// /// + /// 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 GetAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -69,22 +72,43 @@ partial void ProcessGetResponseContent( securityRequirements: s_GetSecurityRequirements, operationName: "GetAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/annotation-reviews/{id}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/annotation-reviews/{id}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,112 +118,271 @@ partial void ProcessGetResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/annotation-reviews/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/annotation-reviews/{id}/\"", + 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); - ProcessGetResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/annotation-reviews/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.AnnotationReview.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.AnnotationReview.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGetResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/annotation-reviews/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/annotation-reviews/{id}/\"", + 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); + ProcessGetResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.AnnotationReview.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.AnnotationReview.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.AnnotationReviews2Client.List.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.AnnotationReviews2Client.List.g.cs index eec27cd..5c9abd6 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.AnnotationReviews2Client.List.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.AnnotationReviews2Client.List.g.cs @@ -14,6 +14,7 @@ public partial class AnnotationReviews2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -57,12 +58,14 @@ partial void ProcessListResponseContent( /// /// /// + /// 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> ListAsync( int? annotation = default, int? annotationTaskProject = default, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -79,27 +82,48 @@ partial void ProcessListResponseContent( securityRequirements: s_ListSecurityRequirements, operationName: "ListAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/annotation-reviews/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("annotation", annotation?.ToString()) - .AddOptionalParameter("annotation__task__project", annotationTaskProject?.ToString()) - .AddOptionalParameter("ordering", ordering) - ; - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/annotation-reviews/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("annotation", annotation?.ToString()) + .AddOptionalParameter("annotation__task__project", annotationTaskProject?.ToString()) + .AddOptionalParameter("ordering", ordering) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -109,114 +133,273 @@ partial void ProcessListResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareListRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - annotation: annotation, - annotationTaskProject: annotationTaskProject, - ordering: ordering); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareListRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + annotation: annotation, + annotationTaskProject: annotationTaskProject, + ordering: ordering); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessListResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/annotation-reviews/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/annotation-reviews/\"", + 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); - ProcessListResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/annotation-reviews/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessListResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/annotation-reviews/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/annotation-reviews/\"", + 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); + ProcessListResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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 + (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.AnnotationReviews2Client.Update.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.AnnotationReviews2Client.Update.g.cs index 7605328..ce9847c 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.AnnotationReviews2Client.Update.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.AnnotationReviews2Client.Update.g.cs @@ -14,6 +14,7 @@ public partial class AnnotationReviews2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -54,12 +55,14 @@ partial void ProcessUpdateResponseContent( /// /// /// + /// 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 UpdateAsync( int id, global::LabelStudio.PatchedAnnotationReviewRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -77,22 +80,43 @@ partial void ProcessUpdateResponseContent( securityRequirements: s_UpdateSecurityRequirements, operationName: "UpdateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/annotation-reviews/{id}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/annotation-reviews/{id}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -102,119 +126,278 @@ partial void ProcessUpdateResponseContent( __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); - PrepareUpdateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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::LabelStudio.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); + PrepareUpdateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessUpdateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/annotation-reviews/{id}/\"", + 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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/annotation-reviews/{id}/\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessUpdateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/annotation-reviews/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.AnnotationReview.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.AnnotationReview.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessUpdateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/annotation-reviews/{id}/\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/annotation-reviews/{id}/\"", + httpMethod: "PATCH", + 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); + ProcessUpdateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.AnnotationReview.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.AnnotationReview.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 review
@@ -240,6 +423,7 @@ partial void ProcessUpdateResponseContent( /// /// /// + /// 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 UpdateAsync( @@ -251,6 +435,7 @@ partial void ProcessUpdateResponseContent( bool? removeFromQueue = default, object? result = default, global::System.DateTime? startedAt = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.PatchedAnnotationReviewRequest @@ -267,6 +452,7 @@ partial void ProcessUpdateResponseContent( return await UpdateAsync( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.AnnotationReviews2Client.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.AnnotationReviews2Client.g.cs index e6135f1..245dbaa 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.AnnotationReviews2Client.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.AnnotationReviews2Client.g.cs @@ -30,6 +30,9 @@ public sealed partial class AnnotationReviews2Client : global::LabelStudio.IAnno #if DEBUG = true; #endif + + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public AnnotationReviews2Client( 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 AnnotationReviews2Client. + /// 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 AnnotationReviews2Client( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::LabelStudio.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::LabelStudio.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/LabelStudio/Generated/LabelStudio.AnnotationReviewsClient.ApiAnnotationReviewsUpdate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.AnnotationReviewsClient.ApiAnnotationReviewsUpdate.g.cs index c6c9a93..719a76f 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.AnnotationReviewsClient.ApiAnnotationReviewsUpdate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.AnnotationReviewsClient.ApiAnnotationReviewsUpdate.g.cs @@ -14,6 +14,7 @@ public partial class AnnotationReviewsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -54,12 +55,14 @@ partial void ProcessApiAnnotationReviewsUpdateResponseContent( ///
/// /// + /// 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 ApiAnnotationReviewsUpdateAsync( int id, global::LabelStudio.AnnotationReviewRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -77,22 +80,43 @@ partial void ProcessApiAnnotationReviewsUpdateResponseContent( securityRequirements: s_ApiAnnotationReviewsUpdateSecurityRequirements, operationName: "ApiAnnotationReviewsUpdateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/annotation-reviews/{id}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/annotation-reviews/{id}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -102,119 +126,278 @@ partial void ProcessApiAnnotationReviewsUpdateResponseContent( __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); - PrepareApiAnnotationReviewsUpdateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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::LabelStudio.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); + PrepareApiAnnotationReviewsUpdateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiAnnotationReviewsUpdateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiAnnotationReviewsUpdate", + methodName: "ApiAnnotationReviewsUpdateAsync", + pathTemplate: "$\"/api/annotation-reviews/{id}/\"", + 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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiAnnotationReviewsUpdate", + methodName: "ApiAnnotationReviewsUpdateAsync", + pathTemplate: "$\"/api/annotation-reviews/{id}/\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessApiAnnotationReviewsUpdateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiAnnotationReviewsUpdate", + methodName: "ApiAnnotationReviewsUpdateAsync", + pathTemplate: "$\"/api/annotation-reviews/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.AnnotationReview.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.AnnotationReview.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessApiAnnotationReviewsUpdateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiAnnotationReviewsUpdate", + methodName: "ApiAnnotationReviewsUpdateAsync", + pathTemplate: "$\"/api/annotation-reviews/{id}/\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiAnnotationReviewsUpdate", + methodName: "ApiAnnotationReviewsUpdateAsync", + pathTemplate: "$\"/api/annotation-reviews/{id}/\"", + httpMethod: "PUT", + 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); + ProcessApiAnnotationReviewsUpdateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.AnnotationReview.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.AnnotationReview.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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(); + } } /// /// ✨ Put review
@@ -240,6 +423,7 @@ partial void ProcessApiAnnotationReviewsUpdateResponseContent( /// /// /// + /// 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 ApiAnnotationReviewsUpdateAsync( @@ -251,6 +435,7 @@ partial void ProcessApiAnnotationReviewsUpdateResponseContent( bool? removeFromQueue = default, object? result = default, global::System.DateTime? startedAt = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.AnnotationReviewRequest @@ -267,6 +452,7 @@ partial void ProcessApiAnnotationReviewsUpdateResponseContent( return await ApiAnnotationReviewsUpdateAsync( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.AnnotationReviewsClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.AnnotationReviewsClient.g.cs index 999c58c..b56e51c 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.AnnotationReviewsClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.AnnotationReviewsClient.g.cs @@ -30,6 +30,9 @@ public sealed partial class AnnotationReviewsClient : global::LabelStudio.IAnnot #if DEBUG = true; #endif + + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public AnnotationReviewsClient( 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 AnnotationReviewsClient. + /// 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 AnnotationReviewsClient( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::LabelStudio.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::LabelStudio.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/LabelStudio/Generated/LabelStudio.AnnotationsClient.Create.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.AnnotationsClient.Create.g.cs index 89089e3..6cc1f9f 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.AnnotationsClient.Create.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.AnnotationsClient.Create.g.cs @@ -14,6 +14,7 @@ public partial class AnnotationsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -61,12 +62,14 @@ partial void ProcessCreateResponseContent( ///
/// /// + /// 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 CreateAsync( int id, global::LabelStudio.ApiTasksAnnotationsCreateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -84,22 +87,43 @@ partial void ProcessCreateResponseContent( securityRequirements: s_CreateSecurityRequirements, operationName: "CreateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/tasks/{id}/annotations/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/tasks/{id}/annotations/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -109,119 +133,278 @@ partial void ProcessCreateResponseContent( __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); - PrepareCreateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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::LabelStudio.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); + PrepareCreateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "$\"/api/tasks/{id}/annotations/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "$\"/api/tasks/{id}/annotations/\"", + 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); - ProcessCreateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "$\"/api/tasks/{id}/annotations/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.Annotation.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.Annotation.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessCreateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "$\"/api/tasks/{id}/annotations/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "$\"/api/tasks/{id}/annotations/\"", + 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); + ProcessCreateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.Annotation.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.Annotation.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 annotation
@@ -267,6 +450,7 @@ partial void ProcessCreateResponseContent( /// /// User skipped the task /// + /// 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 CreateAsync( @@ -279,6 +463,7 @@ partial void ProcessCreateResponseContent( int? task = default, int? updatedBy = default, bool? wasCancelled = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.ApiTasksAnnotationsCreateRequest @@ -296,6 +481,7 @@ partial void ProcessCreateResponseContent( return await CreateAsync( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.AnnotationsClient.CreateBulk.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.AnnotationsClient.CreateBulk.g.cs index 0101e8e..882788e 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.AnnotationsClient.CreateBulk.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.AnnotationsClient.CreateBulk.g.cs @@ -14,6 +14,7 @@ public partial class AnnotationsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,11 +46,13 @@ partial void ProcessCreateBulkResponseContent( /// Create multiple annotations at once ///
/// + /// 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> CreateBulkAsync( global::LabelStudio.AnnotationBulkSerializerWithSelectedItemsRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -66,22 +69,43 @@ partial void ProcessCreateBulkResponseContent( securityRequirements: s_CreateBulkSecurityRequirements, operationName: "CreateBulkAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/annotations/bulk/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/annotations/bulk/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,118 +115,277 @@ partial void ProcessCreateBulkResponseContent( __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::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCreateBulkRequest( - 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); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreateBulkRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreateBulkResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateBulk", + methodName: "CreateBulkAsync", + pathTemplate: "\"/api/annotations/bulk/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateBulk", + methodName: "CreateBulkAsync", + pathTemplate: "\"/api/annotations/bulk/\"", + 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); - ProcessCreateBulkResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateBulk", + methodName: "CreateBulkAsync", + pathTemplate: "\"/api/annotations/bulk/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessCreateBulkResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateBulk", + methodName: "CreateBulkAsync", + pathTemplate: "\"/api/annotations/bulk/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateBulk", + methodName: "CreateBulkAsync", + pathTemplate: "\"/api/annotations/bulk/\"", + 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); + ProcessCreateBulkResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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 + (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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(); + } } /// /// Bulk create annotations
@@ -266,6 +449,7 @@ partial void ProcessCreateBulkResponseContent( /// /// User skipped the task /// + /// 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> CreateBulkAsync( @@ -287,6 +471,7 @@ partial void ProcessCreateBulkResponseContent( global::System.Collections.Generic.IList? tasks = default, int? updatedBy = default, bool? wasCancelled = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.AnnotationBulkSerializerWithSelectedItemsRequest @@ -313,6 +498,7 @@ partial void ProcessCreateBulkResponseContent( return await CreateBulkAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.AnnotationsClient.Delete.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.AnnotationsClient.Delete.g.cs index 7997ed8..331084c 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.AnnotationsClient.Delete.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.AnnotationsClient.Delete.g.cs @@ -14,6 +14,7 @@ public partial class AnnotationsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -40,10 +41,12 @@ partial void ProcessDeleteResponse( /// Delete an annotation. This action can't be undone! ///
/// + /// 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 DeleteAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -58,22 +61,43 @@ partial void ProcessDeleteResponse( securityRequirements: s_DeleteSecurityRequirements, operationName: "DeleteAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/annotations/{id}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/annotations/{id}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -83,96 +107,255 @@ partial void ProcessDeleteResponse( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDeleteRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDeleteRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/annotations/{id}/\"", + 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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/annotations/{id}/\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessDeleteResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/annotations/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessDeleteResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/annotations/{id}/\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/annotations/{id}/\"", + httpMethod: "DELETE", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.AnnotationsClient.DeleteBulk.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.AnnotationsClient.DeleteBulk.g.cs index d2034d4..32a71a9 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.AnnotationsClient.DeleteBulk.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.AnnotationsClient.DeleteBulk.g.cs @@ -14,6 +14,7 @@ public partial class AnnotationsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,11 +46,13 @@ partial void ProcessDeleteBulkResponseContent( /// Delete multiple annotations by their IDs. The deletion is processed synchronously. Returns the count of deleted annotations in the response. /// /// + /// 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 DeleteBulkAsync( global::LabelStudio.AnnotationBulkDeleteRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -66,22 +69,43 @@ partial void ProcessDeleteBulkResponseContent( securityRequirements: s_DeleteBulkSecurityRequirements, operationName: "DeleteBulkAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/annotations/bulk-delete/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/annotations/bulk-delete/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,184 +115,343 @@ partial void ProcessDeleteBulkResponseContent( __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); - PrepareDeleteBulkRequest( - 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::LabelStudio.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); + PrepareDeleteBulkRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessDeleteBulkResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // - if ((int)__response.StatusCode == 400) + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_400 = null; - global::System.Exception? __exception_400 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteBulk", + methodName: "DeleteBulkAsync", + pathTemplate: "\"/api/annotations/bulk-delete/\"", + 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_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + __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_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - } - } - catch (global::System.Exception __ex) - { - __exception_400 = __ex; - } + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteBulk", + methodName: "DeleteBulkAsync", + pathTemplate: "\"/api/annotations/bulk-delete/\"", + 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; + } - throw new global::LabelStudio.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 == 403) - { - string? __content_403 = null; - global::System.Exception? __exception_403 = null; - try - { - if (ReadResponseAsString) - { - __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else + + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteBulk", + methodName: "DeleteBulkAsync", + pathTemplate: "\"/api/annotations/bulk-delete/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_403 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::LabelStudio.ApiException( - message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_403, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_403, - 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); - ProcessDeleteBulkResponseContent( + response: __response); + ProcessDeleteBulkResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::LabelStudio.ApiAnnotationsBulkDeleteCreateResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteBulk", + methodName: "DeleteBulkAsync", + pathTemplate: "\"/api/annotations/bulk-delete/\"", + 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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteBulk", + methodName: "DeleteBulkAsync", + pathTemplate: "\"/api/annotations/bulk-delete/\"", + 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); + // + 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; + } - return - await global::LabelStudio.ApiAnnotationsBulkDeleteCreateResponse.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) - { - } + throw new global::LabelStudio.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 == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } + + throw new global::LabelStudio.ApiException( + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + statusCode: __response.StatusCode) + { + ResponseBody = __content_403, + 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); + ProcessDeleteBulkResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.ApiAnnotationsBulkDeleteCreateResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiAnnotationsBulkDeleteCreateResponse.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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(); + } } /// /// Bulk delete annotations by IDs
@@ -278,11 +461,13 @@ partial void ProcessDeleteBulkResponseContent( /// List of annotation IDs 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 DeleteBulkAsync( global::System.Collections.Generic.IList ids, int project, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.AnnotationBulkDeleteRequest @@ -293,6 +478,7 @@ partial void ProcessDeleteBulkResponseContent( return await DeleteBulkAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.AnnotationsClient.Get.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.AnnotationsClient.Get.g.cs index 5d37ad4..4a00ff0 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.AnnotationsClient.Get.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.AnnotationsClient.Get.g.cs @@ -14,6 +14,7 @@ public partial class AnnotationsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,10 +46,12 @@ partial void ProcessGetResponseContent( /// Retrieve a specific annotation for a task using the annotation result ID. ///
/// + /// 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 GetAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -63,22 +66,43 @@ partial void ProcessGetResponseContent( securityRequirements: s_GetSecurityRequirements, operationName: "GetAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/annotations/{id}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/annotations/{id}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -88,112 +112,271 @@ partial void ProcessGetResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/annotations/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/annotations/{id}/\"", + 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); - ProcessGetResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/annotations/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.Annotation.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.Annotation.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGetResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/annotations/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/annotations/{id}/\"", + 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); + ProcessGetResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.Annotation.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.Annotation.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.AnnotationsClient.List.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.AnnotationsClient.List.g.cs index 4165d2f..ebe3cc0 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.AnnotationsClient.List.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.AnnotationsClient.List.g.cs @@ -14,6 +14,7 @@ public partial class AnnotationsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -48,11 +49,13 @@ partial void ProcessListResponseContent( /// /// /// + /// 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> ListAsync( int id, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -68,25 +71,46 @@ partial void ProcessListResponseContent( securityRequirements: s_ListSecurityRequirements, operationName: "ListAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/tasks/{id}/annotations/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("ordering", ordering) - ; - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/tasks/{id}/annotations/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("ordering", ordering) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -96,113 +120,272 @@ partial void ProcessListResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareListRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - ordering: ordering); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareListRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + ordering: ordering); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessListResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "$\"/api/tasks/{id}/annotations/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "$\"/api/tasks/{id}/annotations/\"", + 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); - ProcessListResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "$\"/api/tasks/{id}/annotations/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessListResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "$\"/api/tasks/{id}/annotations/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "$\"/api/tasks/{id}/annotations/\"", + 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); + ProcessListResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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 + (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.AnnotationsClient.Update.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.AnnotationsClient.Update.g.cs index 3755fc2..9c1b2d0 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.AnnotationsClient.Update.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.AnnotationsClient.Update.g.cs @@ -14,6 +14,7 @@ public partial class AnnotationsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -48,12 +49,14 @@ partial void ProcessUpdateResponseContent( /// /// /// + /// 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 UpdateAsync( int id, global::LabelStudio.ApiAnnotationsPartialUpdateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -71,22 +74,43 @@ partial void ProcessUpdateResponseContent( securityRequirements: s_UpdateSecurityRequirements, operationName: "UpdateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/annotations/{id}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/annotations/{id}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -96,119 +120,278 @@ partial void ProcessUpdateResponseContent( __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); - PrepareUpdateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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::LabelStudio.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); + PrepareUpdateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessUpdateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/annotations/{id}/\"", + 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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/annotations/{id}/\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessUpdateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/annotations/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.Annotation.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.Annotation.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessUpdateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/annotations/{id}/\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/annotations/{id}/\"", + httpMethod: "PATCH", + 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); + ProcessUpdateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.Annotation.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.Annotation.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 annotation
@@ -241,6 +424,7 @@ partial void ProcessUpdateResponseContent( /// /// User skipped the task /// + /// 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 UpdateAsync( @@ -253,6 +437,7 @@ partial void ProcessUpdateResponseContent( int? task = default, int? updatedBy = default, bool? wasCancelled = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.ApiAnnotationsPartialUpdateRequest @@ -270,6 +455,7 @@ partial void ProcessUpdateResponseContent( return await UpdateAsync( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.AnnotationsClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.AnnotationsClient.g.cs index c2f0d9b..fa29d15 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.AnnotationsClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.AnnotationsClient.g.cs @@ -30,6 +30,9 @@ public sealed partial class AnnotationsClient : global::LabelStudio.IAnnotations #if DEBUG = true; #endif + + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public AnnotationsClient( 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 AnnotationsClient. + /// 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 AnnotationsClient( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::LabelStudio.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::LabelStudio.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/LabelStudio/Generated/LabelStudio.AwsClient.Logs.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.AwsClient.Logs.g.cs index 00f67cc..3428e1b 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.AwsClient.Logs.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.AwsClient.Logs.g.cs @@ -14,6 +14,7 @@ public partial class AwsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -62,6 +63,7 @@ partial void ProcessLogsResponseContent( /// Default Value: 100 /// /// + /// 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 LogsAsync( @@ -69,6 +71,7 @@ partial void ProcessLogsResponseContent( string? endDate = default, int? limit = default, string? startDate = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -86,27 +89,48 @@ partial void ProcessLogsResponseContent( securityRequirements: s_LogsSecurityRequirements, operationName: "LogsAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{id}/aws-custom-function-logs", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("end_date", endDate) - .AddOptionalParameter("limit", limit?.ToString()) - .AddOptionalParameter("start_date", startDate) - ; - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{id}/aws-custom-function-logs", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("end_date", endDate) + .AddOptionalParameter("limit", limit?.ToString()) + .AddOptionalParameter("start_date", startDate) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -116,111 +140,270 @@ partial void ProcessLogsResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareLogsRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - endDate: endDate, - id: id, - limit: limit, - startDate: startDate); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareLogsRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + endDate: endDate, + id: id, + limit: limit, + startDate: startDate); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessLogsResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Logs", + methodName: "LogsAsync", + pathTemplate: "$\"/api/projects/{id}/aws-custom-function-logs\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Logs", + methodName: "LogsAsync", + pathTemplate: "$\"/api/projects/{id}/aws-custom-function-logs\"", + 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); - ProcessLogsResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Logs", + methodName: "LogsAsync", + pathTemplate: "$\"/api/projects/{id}/aws-custom-function-logs\"", + 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::LabelStudio.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::LabelStudio.ApiException( - message: __content ?? __response.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); + ProcessLogsResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Logs", + methodName: "LogsAsync", + pathTemplate: "$\"/api/projects/{id}/aws-custom-function-logs\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Logs", + methodName: "LogsAsync", + pathTemplate: "$\"/api/projects/{id}/aws-custom-function-logs\"", + 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); + ProcessLogsResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return __content; + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.AwsClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.AwsClient.g.cs index b410e81..651e97e 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.AwsClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.AwsClient.g.cs @@ -30,6 +30,9 @@ public sealed partial class AwsClient : global::LabelStudio.IAwsClient, global:: #if DEBUG = true; #endif + + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public AwsClient( 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 AwsClient. + /// 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 AwsClient( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::LabelStudio.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::LabelStudio.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/LabelStudio/Generated/LabelStudio.BillingClient.Info.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.BillingClient.Info.g.cs index 8751c8f..80d3bb9 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.BillingClient.Info.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.BillingClient.Info.g.cs @@ -14,6 +14,7 @@ public partial class BillingClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -48,9 +49,11 @@ partial void ProcessInfoResponseContent( /// </Card>
/// Retrieve billing checks and feature flags for the active 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 InfoAsync( + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -64,22 +67,43 @@ partial void ProcessInfoResponseContent( securityRequirements: s_InfoSecurityRequirements, operationName: "InfoAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/billing/info", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/billing/info", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,111 +113,270 @@ partial void ProcessInfoResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - 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); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareInfoRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessInfoResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Info", + methodName: "InfoAsync", + pathTemplate: "\"/api/billing/info\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Info", + methodName: "InfoAsync", + pathTemplate: "\"/api/billing/info\"", + 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); - ProcessInfoResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Info", + methodName: "InfoAsync", + pathTemplate: "\"/api/billing/info\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.BillingInfoResponse.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.BillingInfoResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessInfoResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Info", + methodName: "InfoAsync", + pathTemplate: "\"/api/billing/info\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Info", + methodName: "InfoAsync", + pathTemplate: "\"/api/billing/info\"", + 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); + ProcessInfoResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.BillingInfoResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.BillingInfoResponse.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.BillingClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.BillingClient.g.cs index 5f96bfb..15627e0 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.BillingClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.BillingClient.g.cs @@ -30,6 +30,9 @@ public sealed partial class BillingClient : global::LabelStudio.IBillingClient, #if DEBUG = true; #endif + + /// + public global::LabelStudio.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::LabelStudio.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::LabelStudio.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/LabelStudio/Generated/LabelStudio.Blueprints2Client.Create.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Blueprints2Client.Create.g.cs index ac22e5c..4a87a01 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Blueprints2Client.Create.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Blueprints2Client.Create.g.cs @@ -14,6 +14,7 @@ public partial class Blueprints2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,11 +46,13 @@ partial void ProcessCreateResponseContent( /// Create a new blueprint /// /// + /// 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 CreateAsync( global::LabelStudio.BlueprintRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -66,22 +69,43 @@ partial void ProcessCreateResponseContent( securityRequirements: s_CreateSecurityRequirements, operationName: "CreateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/blueprints/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/blueprints/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,118 +115,277 @@ partial void ProcessCreateResponseContent( __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); - PrepareCreateRequest( - 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::LabelStudio.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); + PrepareCreateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/blueprints/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/blueprints/\"", + 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); - ProcessCreateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/blueprints/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.Blueprint.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.Blueprint.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessCreateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/blueprints/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/blueprints/\"", + 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); + ProcessCreateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.Blueprint.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.Blueprint.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 blueprint
@@ -222,6 +405,7 @@ partial void ProcessCreateResponseContent( /// /// Blueprint name. Must be between 3 and 50 characters long. /// + /// 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 CreateAsync( @@ -231,6 +415,7 @@ partial void ProcessCreateResponseContent( string? description = default, string? labelConfig = default, string? title = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.BlueprintRequest @@ -245,6 +430,7 @@ partial void ProcessCreateResponseContent( return await CreateAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.Blueprints2Client.Delete.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Blueprints2Client.Delete.g.cs index ac84eb3..d80bdaa 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Blueprints2Client.Delete.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Blueprints2Client.Delete.g.cs @@ -14,6 +14,7 @@ public partial class Blueprints2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -40,10 +41,12 @@ partial void ProcessDeleteResponse( /// Delete a blueprint by ID ///
/// + /// 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 DeleteAsync( string id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -58,22 +61,43 @@ partial void ProcessDeleteResponse( securityRequirements: s_DeleteSecurityRequirements, operationName: "DeleteAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/blueprints/{id}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/blueprints/{id}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -83,96 +107,255 @@ partial void ProcessDeleteResponse( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDeleteRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDeleteRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/blueprints/{id}/\"", + 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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/blueprints/{id}/\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessDeleteResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/blueprints/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessDeleteResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/blueprints/{id}/\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/blueprints/{id}/\"", + httpMethod: "DELETE", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.Blueprints2Client.Update.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Blueprints2Client.Update.g.cs index 6a0ed59..49403eb 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Blueprints2Client.Update.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Blueprints2Client.Update.g.cs @@ -14,6 +14,7 @@ public partial class Blueprints2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -48,12 +49,14 @@ partial void ProcessUpdateResponseContent( /// /// /// + /// 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 UpdateAsync( string id, global::LabelStudio.PatchedBlueprintUpdateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -71,22 +74,43 @@ partial void ProcessUpdateResponseContent( securityRequirements: s_UpdateSecurityRequirements, operationName: "UpdateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/blueprints/{id}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/blueprints/{id}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -96,119 +120,278 @@ partial void ProcessUpdateResponseContent( __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); - PrepareUpdateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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::LabelStudio.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); + PrepareUpdateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessUpdateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/blueprints/{id}/\"", + 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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/blueprints/{id}/\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessUpdateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/blueprints/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.Blueprint.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.Blueprint.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessUpdateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/blueprints/{id}/\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/blueprints/{id}/\"", + httpMethod: "PATCH", + 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); + ProcessUpdateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.Blueprint.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.Blueprint.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 blueprint
@@ -224,6 +407,7 @@ partial void ProcessUpdateResponseContent( /// /// Blueprint name. Must be between 3 and 50 characters long. /// + /// 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 UpdateAsync( @@ -231,6 +415,7 @@ partial void ProcessUpdateResponseContent( global::System.Collections.Generic.IList taskIds, string? description = default, string? title = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.PatchedBlueprintUpdateRequest @@ -243,6 +428,7 @@ partial void ProcessUpdateResponseContent( return await UpdateAsync( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.Blueprints2Client.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Blueprints2Client.g.cs index ff732b3..b258541 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Blueprints2Client.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Blueprints2Client.g.cs @@ -30,6 +30,9 @@ public sealed partial class Blueprints2Client : global::LabelStudio.IBlueprints2 #if DEBUG = true; #endif + + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public Blueprints2Client( 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 Blueprints2Client. + /// 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 Blueprints2Client( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::LabelStudio.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::LabelStudio.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/LabelStudio/Generated/LabelStudio.BlueprintsClient.ApiBlueprintsCreateProjectRetrieve.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.BlueprintsClient.ApiBlueprintsCreateProjectRetrieve.g.cs index 911c9f2..46e9940 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.BlueprintsClient.ApiBlueprintsCreateProjectRetrieve.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.BlueprintsClient.ApiBlueprintsCreateProjectRetrieve.g.cs @@ -34,10 +34,12 @@ partial void ProcessApiBlueprintsCreateProjectRetrieveResponse( /// Create a new project from an existing blueprint. On success, user is redirected to the new project with a 302. ///
/// + /// 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 ApiBlueprintsCreateProjectRetrieveAsync( string shareId, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -52,170 +54,349 @@ partial void ProcessApiBlueprintsCreateProjectRetrieveResponse( securityRequirements: s_ApiBlueprintsCreateProjectRetrieveSecurityRequirements, operationName: "ApiBlueprintsCreateProjectRetrieveAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/blueprints/{shareId}/create-project", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/blueprints/{shareId}/create-project", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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 + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareApiBlueprintsCreateProjectRetrieveRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - shareId: shareId); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareApiBlueprintsCreateProjectRetrieveRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + shareId: shareId); - 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); - ProcessApiBlueprintsCreateProjectRetrieveResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // - if ((int)__response.StatusCode == 302) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_302 = null; - global::System.Exception? __exception_302 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiBlueprintsCreateProjectRetrieve", + methodName: "ApiBlueprintsCreateProjectRetrieveAsync", + pathTemplate: "$\"/api/blueprints/{shareId}/create-project\"", + 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_302 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + __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_302 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiBlueprintsCreateProjectRetrieve", + methodName: "ApiBlueprintsCreateProjectRetrieveAsync", + pathTemplate: "$\"/api/blueprints/{shareId}/create-project\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiBlueprintsCreateProjectRetrieve", + methodName: "ApiBlueprintsCreateProjectRetrieveAsync", + pathTemplate: "$\"/api/blueprints/{shareId}/create-project\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_302 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::LabelStudio.ApiException( - message: __content_302 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_302, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_302, - 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); + ProcessApiBlueprintsCreateProjectRetrieveResponse( + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiBlueprintsCreateProjectRetrieve", + methodName: "ApiBlueprintsCreateProjectRetrieveAsync", + pathTemplate: "$\"/api/blueprints/{shareId}/create-project\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiBlueprintsCreateProjectRetrieve", + methodName: "ApiBlueprintsCreateProjectRetrieveAsync", + pathTemplate: "$\"/api/blueprints/{shareId}/create-project\"", + 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 ((int)__response.StatusCode == 302) + { + string? __content_302 = null; + global::System.Exception? __exception_302 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_302 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_302 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_302 = __ex; + } - throw new global::LabelStudio.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), - }; - } + throw new global::LabelStudio.ApiException( + message: __content_302 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_302, + statusCode: __response.StatusCode) + { + ResponseBody = __content_302, + 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::LabelStudio.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), + }; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); - try - { - __response.EnsureSuccessStatusCode(); + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.BlueprintsClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.BlueprintsClient.g.cs index 6bc861a..a5f1967 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.BlueprintsClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.BlueprintsClient.g.cs @@ -30,6 +30,9 @@ public sealed partial class BlueprintsClient : global::LabelStudio.IBlueprintsCl #if DEBUG = true; #endif + + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public BlueprintsClient( 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 BlueprintsClient. + /// 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 BlueprintsClient( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::LabelStudio.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::LabelStudio.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/LabelStudio/Generated/LabelStudio.Comments2Client.Create.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Comments2Client.Create.g.cs index a749910..73d7d48 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Comments2Client.Create.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Comments2Client.Create.g.cs @@ -14,6 +14,7 @@ public partial class Comments2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -54,12 +55,14 @@ partial void ProcessCreateResponseContent( /// /// /// + /// 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 CreateAsync( global::LabelStudio.CommentRequest request, bool? expandCreatedBy = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -77,25 +80,46 @@ partial void ProcessCreateResponseContent( securityRequirements: s_CreateSecurityRequirements, operationName: "CreateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/comments/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("expand_created_by", expandCreatedBy?.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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/comments/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("expand_created_by", expandCreatedBy?.ToString().ToLowerInvariant()) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,119 +129,278 @@ partial void ProcessCreateResponseContent( __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); - PrepareCreateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - expandCreatedBy: expandCreatedBy, - 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::LabelStudio.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); + PrepareCreateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + expandCreatedBy: expandCreatedBy, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/comments/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/comments/\"", + 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); - ProcessCreateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/comments/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.MaybeExpandedComment.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.MaybeExpandedComment.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessCreateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/comments/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/comments/\"", + 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); + ProcessCreateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.MaybeExpandedComment.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.MaybeExpandedComment.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 comment
@@ -244,6 +427,7 @@ partial void ProcessCreateResponseContent( /// /// Reviewer or annotator comment /// + /// 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 CreateAsync( @@ -254,6 +438,7 @@ partial void ProcessCreateResponseContent( bool? isResolved = default, object? regionRef = default, string? text = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.CommentRequest @@ -269,6 +454,7 @@ partial void ProcessCreateResponseContent( return await CreateAsync( expandCreatedBy: expandCreatedBy, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.Comments2Client.Delete.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Comments2Client.Delete.g.cs index b9f7f5f..af35fdc 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Comments2Client.Delete.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Comments2Client.Delete.g.cs @@ -14,6 +14,7 @@ public partial class Comments2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -49,11 +50,13 @@ partial void ProcessDeleteResponse( ///
/// /// + /// 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 DeleteAsync( string id, bool? expandCreatedBy = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -69,25 +72,46 @@ partial void ProcessDeleteResponse( securityRequirements: s_DeleteSecurityRequirements, operationName: "DeleteAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/comments/{id}/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("expand_created_by", expandCreatedBy?.ToString().ToLowerInvariant()) - ; - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/comments/{id}/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("expand_created_by", expandCreatedBy?.ToString().ToLowerInvariant()) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -97,97 +121,256 @@ partial void ProcessDeleteResponse( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDeleteRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - expandCreatedBy: expandCreatedBy, - id: id); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDeleteRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + expandCreatedBy: expandCreatedBy, + id: id); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/comments/{id}/\"", + 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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/comments/{id}/\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessDeleteResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/comments/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessDeleteResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/comments/{id}/\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/comments/{id}/\"", + httpMethod: "DELETE", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.Comments2Client.Export.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Comments2Client.Export.g.cs index f736c86..c806882 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Comments2Client.Export.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Comments2Client.Export.g.cs @@ -14,6 +14,7 @@ public partial class Comments2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -68,6 +69,7 @@ partial void ProcessExportResponseContent( /// /// /// + /// 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 ExportAsync( @@ -77,6 +79,7 @@ partial void ProcessExportResponseContent( bool? expandCreatedBy = default, string? projects = default, string? tz = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -96,30 +99,51 @@ partial void ProcessExportResponseContent( securityRequirements: s_ExportSecurityRequirements, operationName: "ExportAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/comments/export/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("annotation", annotation?.ToString()) - .AddOptionalParameter("annotators", annotators) - .AddOptionalParameter("draft", draft?.ToString()) - .AddOptionalParameter("expand_created_by", expandCreatedBy?.ToString().ToLowerInvariant()) - .AddOptionalParameter("projects", projects) - .AddOptionalParameter("tz", tz) - ; - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/comments/export/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("annotation", annotation?.ToString()) + .AddOptionalParameter("annotators", annotators) + .AddOptionalParameter("draft", draft?.ToString()) + .AddOptionalParameter("expand_created_by", expandCreatedBy?.ToString().ToLowerInvariant()) + .AddOptionalParameter("projects", projects) + .AddOptionalParameter("tz", tz) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -129,108 +153,267 @@ partial void ProcessExportResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareExportRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - annotation: annotation, - annotators: annotators, - draft: draft, - expandCreatedBy: expandCreatedBy, - projects: projects, - tz: tz); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareExportRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + annotation: annotation, + annotators: annotators, + draft: draft, + expandCreatedBy: expandCreatedBy, + projects: projects, + tz: tz); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessExportResponse( - 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.ReadAsByteArrayAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Export", + methodName: "ExportAsync", + pathTemplate: "\"/api/comments/export/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Export", + methodName: "ExportAsync", + pathTemplate: "\"/api/comments/export/\"", + 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; + } - ProcessExportResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Export", + methodName: "ExportAsync", + pathTemplate: "\"/api/comments/export/\"", + 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::LabelStudio.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::LabelStudio.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), - }; + throw new global::System.InvalidOperationException("No response received."); } - } - else - { - try + + using (__response) { - __response.EnsureSuccessStatusCode(); - var __content = await __response.Content.ReadAsByteArrayAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - return __content; + ProcessResponse( + client: HttpClient, + response: __response); + ProcessExportResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Export", + methodName: "ExportAsync", + pathTemplate: "\"/api/comments/export/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Export", + methodName: "ExportAsync", + pathTemplate: "\"/api/comments/export/\"", + 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.ReadAsByteArrayAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessExportResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return __content; + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.Comments2Client.Get.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Comments2Client.Get.g.cs index cd4346f..1ec5563 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Comments2Client.Get.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Comments2Client.Get.g.cs @@ -14,6 +14,7 @@ public partial class Comments2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -54,11 +55,13 @@ partial void ProcessGetResponseContent( /// /// /// + /// 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 GetAsync( string id, bool? expandCreatedBy = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -74,25 +77,46 @@ partial void ProcessGetResponseContent( securityRequirements: s_GetSecurityRequirements, operationName: "GetAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/comments/{id}/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("expand_created_by", expandCreatedBy?.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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/comments/{id}/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("expand_created_by", expandCreatedBy?.ToString().ToLowerInvariant()) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,113 +126,272 @@ partial void ProcessGetResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - expandCreatedBy: expandCreatedBy, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + expandCreatedBy: expandCreatedBy, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/comments/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/comments/{id}/\"", + 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); - ProcessGetResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/comments/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.MaybeExpandedComment.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.MaybeExpandedComment.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGetResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/comments/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/comments/{id}/\"", + 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); + ProcessGetResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.MaybeExpandedComment.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.MaybeExpandedComment.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.Comments2Client.List.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Comments2Client.List.g.cs index 2a1ac47..3f1fc40 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Comments2Client.List.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Comments2Client.List.g.cs @@ -14,6 +14,7 @@ public partial class Comments2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -68,6 +69,7 @@ partial void ProcessListResponseContent( /// /// /// + /// 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> ListAsync( @@ -77,6 +79,7 @@ partial void ProcessListResponseContent( bool? expandCreatedBy = default, string? ordering = default, string? projects = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -96,30 +99,51 @@ partial void ProcessListResponseContent( securityRequirements: s_ListSecurityRequirements, operationName: "ListAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/comments/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("annotation", annotation?.ToString()) - .AddOptionalParameter("annotators", annotators) - .AddOptionalParameter("draft", draft?.ToString()) - .AddOptionalParameter("expand_created_by", expandCreatedBy?.ToString().ToLowerInvariant()) - .AddOptionalParameter("ordering", ordering) - .AddOptionalParameter("projects", projects) - ; - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/comments/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("annotation", annotation?.ToString()) + .AddOptionalParameter("annotators", annotators) + .AddOptionalParameter("draft", draft?.ToString()) + .AddOptionalParameter("expand_created_by", expandCreatedBy?.ToString().ToLowerInvariant()) + .AddOptionalParameter("ordering", ordering) + .AddOptionalParameter("projects", projects) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -129,117 +153,276 @@ partial void ProcessListResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareListRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - annotation: annotation, - annotators: annotators, - draft: draft, - expandCreatedBy: expandCreatedBy, - ordering: ordering, - projects: projects); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareListRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + annotation: annotation, + annotators: annotators, + draft: draft, + expandCreatedBy: expandCreatedBy, + ordering: ordering, + projects: projects); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessListResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/comments/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/comments/\"", + 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); - ProcessListResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/comments/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessListResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/comments/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/comments/\"", + 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); + ProcessListResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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 + (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.Comments2Client.Update.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Comments2Client.Update.g.cs index 34f5b23..1e58b26 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Comments2Client.Update.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Comments2Client.Update.g.cs @@ -14,6 +14,7 @@ public partial class Comments2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -57,6 +58,7 @@ partial void ProcessUpdateResponseContent( /// /// /// + /// 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 UpdateAsync( @@ -64,6 +66,7 @@ partial void ProcessUpdateResponseContent( global::LabelStudio.PatchedCommentRequest request, bool? expandCreatedBy = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -82,25 +85,46 @@ partial void ProcessUpdateResponseContent( securityRequirements: s_UpdateSecurityRequirements, operationName: "UpdateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/comments/{id}/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("expand_created_by", expandCreatedBy?.ToString().ToLowerInvariant()) - ; - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/comments/{id}/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("expand_created_by", expandCreatedBy?.ToString().ToLowerInvariant()) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -110,120 +134,279 @@ partial void ProcessUpdateResponseContent( __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); - PrepareUpdateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - expandCreatedBy: expandCreatedBy, - id: id, - 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::LabelStudio.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); + PrepareUpdateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + expandCreatedBy: expandCreatedBy, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessUpdateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/comments/{id}/\"", + 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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/comments/{id}/\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessUpdateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/comments/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.MaybeExpandedComment.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.MaybeExpandedComment.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessUpdateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/comments/{id}/\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/comments/{id}/\"", + httpMethod: "PATCH", + 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); + ProcessUpdateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.MaybeExpandedComment.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.MaybeExpandedComment.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 comment
@@ -251,6 +434,7 @@ partial void ProcessUpdateResponseContent( /// /// Reviewer or annotator comment /// + /// 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 UpdateAsync( @@ -262,6 +446,7 @@ partial void ProcessUpdateResponseContent( bool? isResolved = default, object? regionRef = default, string? text = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.PatchedCommentRequest @@ -278,6 +463,7 @@ partial void ProcessUpdateResponseContent( expandCreatedBy: expandCreatedBy, id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.Comments2Client.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Comments2Client.g.cs index d1ebde9..101ecf6 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Comments2Client.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Comments2Client.g.cs @@ -30,6 +30,9 @@ public sealed partial class Comments2Client : global::LabelStudio.IComments2Clie #if DEBUG = true; #endif + + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public Comments2Client( 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 Comments2Client. + /// 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 Comments2Client( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::LabelStudio.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::LabelStudio.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/LabelStudio/Generated/LabelStudio.CommentsClient.ApiCommentsUpdate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.CommentsClient.ApiCommentsUpdate.g.cs index ba7f44b..0aaf2aa 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.CommentsClient.ApiCommentsUpdate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.CommentsClient.ApiCommentsUpdate.g.cs @@ -14,6 +14,7 @@ public partial class CommentsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -57,6 +58,7 @@ partial void ProcessApiCommentsUpdateResponseContent( /// /// /// + /// 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 ApiCommentsUpdateAsync( @@ -64,6 +66,7 @@ partial void ProcessApiCommentsUpdateResponseContent( global::LabelStudio.CommentRequest request, bool? expandCreatedBy = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -82,25 +85,46 @@ partial void ProcessApiCommentsUpdateResponseContent( securityRequirements: s_ApiCommentsUpdateSecurityRequirements, operationName: "ApiCommentsUpdateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/comments/{id}/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("expand_created_by", expandCreatedBy?.ToString().ToLowerInvariant()) - ; - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/comments/{id}/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("expand_created_by", expandCreatedBy?.ToString().ToLowerInvariant()) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -110,120 +134,279 @@ partial void ProcessApiCommentsUpdateResponseContent( __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); - PrepareApiCommentsUpdateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - expandCreatedBy: expandCreatedBy, - id: id, - 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::LabelStudio.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); + PrepareApiCommentsUpdateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + expandCreatedBy: expandCreatedBy, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiCommentsUpdateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiCommentsUpdate", + methodName: "ApiCommentsUpdateAsync", + pathTemplate: "$\"/api/comments/{id}/\"", + 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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiCommentsUpdate", + methodName: "ApiCommentsUpdateAsync", + pathTemplate: "$\"/api/comments/{id}/\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessApiCommentsUpdateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiCommentsUpdate", + methodName: "ApiCommentsUpdateAsync", + pathTemplate: "$\"/api/comments/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.Comment.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.Comment.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessApiCommentsUpdateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiCommentsUpdate", + methodName: "ApiCommentsUpdateAsync", + pathTemplate: "$\"/api/comments/{id}/\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiCommentsUpdate", + methodName: "ApiCommentsUpdateAsync", + pathTemplate: "$\"/api/comments/{id}/\"", + httpMethod: "PUT", + 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); + ProcessApiCommentsUpdateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.Comment.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.Comment.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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(); + } } /// /// ✨ Put comment
@@ -251,6 +434,7 @@ partial void ProcessApiCommentsUpdateResponseContent( /// /// Reviewer or annotator comment /// + /// 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 ApiCommentsUpdateAsync( @@ -262,6 +446,7 @@ partial void ProcessApiCommentsUpdateResponseContent( bool? isResolved = default, object? regionRef = default, string? text = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.CommentRequest @@ -278,6 +463,7 @@ partial void ProcessApiCommentsUpdateResponseContent( expandCreatedBy: expandCreatedBy, id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.CommentsClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.CommentsClient.g.cs index bf8e5b3..4ee7210 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.CommentsClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.CommentsClient.g.cs @@ -30,6 +30,9 @@ public sealed partial class CommentsClient : global::LabelStudio.ICommentsClient #if DEBUG = true; #endif + + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public CommentsClient( 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 CommentsClient. + /// 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 CommentsClient( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::LabelStudio.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::LabelStudio.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/LabelStudio/Generated/LabelStudio.DataExplorerClient.ApiDatasetsColumnsRetrieve.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.DataExplorerClient.ApiDatasetsColumnsRetrieve.g.cs index 4f0cbd0..fa68d38 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.DataExplorerClient.ApiDatasetsColumnsRetrieve.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.DataExplorerClient.ApiDatasetsColumnsRetrieve.g.cs @@ -14,6 +14,7 @@ public partial class DataExplorerClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -40,10 +41,12 @@ partial void ProcessApiDatasetsColumnsRetrieveResponse( /// Retrieve the data explorer columns available for a specific Dataset. ///
/// + /// 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 ApiDatasetsColumnsRetrieveAsync( int? dataset = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -58,25 +61,46 @@ partial void ProcessApiDatasetsColumnsRetrieveResponse( securityRequirements: s_ApiDatasetsColumnsRetrieveSecurityRequirements, operationName: "ApiDatasetsColumnsRetrieveAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/datasets/columns", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("dataset", dataset?.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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/datasets/columns", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("dataset", dataset?.ToString()) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -86,96 +110,255 @@ partial void ProcessApiDatasetsColumnsRetrieveResponse( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareApiDatasetsColumnsRetrieveRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - dataset: dataset); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareApiDatasetsColumnsRetrieveRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + dataset: dataset); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsColumnsRetrieve", + methodName: "ApiDatasetsColumnsRetrieveAsync", + pathTemplate: "\"/api/datasets/columns\"", + 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: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsColumnsRetrieve", + methodName: "ApiDatasetsColumnsRetrieveAsync", + pathTemplate: "\"/api/datasets/columns\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiDatasetsColumnsRetrieveResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsColumnsRetrieve", + methodName: "ApiDatasetsColumnsRetrieveAsync", + pathTemplate: "\"/api/datasets/columns\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessApiDatasetsColumnsRetrieveResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsColumnsRetrieve", + methodName: "ApiDatasetsColumnsRetrieveAsync", + pathTemplate: "\"/api/datasets/columns\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsColumnsRetrieve", + methodName: "ApiDatasetsColumnsRetrieveAsync", + pathTemplate: "\"/api/datasets/columns\"", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.DataExplorerClient.ApiDatasetsImportCreate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.DataExplorerClient.ApiDatasetsImportCreate.g.cs index 99ff893..636829d 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.DataExplorerClient.ApiDatasetsImportCreate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.DataExplorerClient.ApiDatasetsImportCreate.g.cs @@ -14,6 +14,7 @@ public partial class DataExplorerClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -56,6 +57,7 @@ partial void ProcessApiDatasetsImportCreateResponse( /// /// /// + /// 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 ApiDatasetsImportCreateAsync( @@ -65,6 +67,7 @@ partial void ProcessApiDatasetsImportCreateResponse( object? included = default, int? project = default, int? view = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -84,30 +87,51 @@ partial void ProcessApiDatasetsImportCreateResponse( securityRequirements: s_ApiDatasetsImportCreateSecurityRequirements, operationName: "ApiDatasetsImportCreateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/datasets/import", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("additional_filters", additionalFilters?.ToString()) - .AddOptionalParameter("dataset", dataset?.ToString()) - .AddOptionalParameter("excluded", excluded?.ToString()) - .AddOptionalParameter("included", included?.ToString()) - .AddOptionalParameter("project", project?.ToString()) - .AddOptionalParameter("view", view?.ToString()) - ; - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/datasets/import", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("additional_filters", additionalFilters?.ToString()) + .AddOptionalParameter("dataset", dataset?.ToString()) + .AddOptionalParameter("excluded", excluded?.ToString()) + .AddOptionalParameter("included", included?.ToString()) + .AddOptionalParameter("project", project?.ToString()) + .AddOptionalParameter("view", view?.ToString()) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -117,101 +141,260 @@ partial void ProcessApiDatasetsImportCreateResponse( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareApiDatasetsImportCreateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - additionalFilters: additionalFilters, - dataset: dataset, - excluded: excluded, - included: included, - project: project, - view: view); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareApiDatasetsImportCreateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + additionalFilters: additionalFilters, + dataset: dataset, + excluded: excluded, + included: included, + project: project, + view: view); + + return __httpRequest; + } - using var __response = await HttpClient.SendAsync( + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsImportCreate", + methodName: "ApiDatasetsImportCreateAsync", + pathTemplate: "\"/api/datasets/import\"", + 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: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsImportCreate", + methodName: "ApiDatasetsImportCreateAsync", + pathTemplate: "\"/api/datasets/import\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiDatasetsImportCreateResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsImportCreate", + methodName: "ApiDatasetsImportCreateAsync", + pathTemplate: "\"/api/datasets/import\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessApiDatasetsImportCreateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsImportCreate", + methodName: "ApiDatasetsImportCreateAsync", + pathTemplate: "\"/api/datasets/import\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsImportCreate", + methodName: "ApiDatasetsImportCreateAsync", + pathTemplate: "\"/api/datasets/import\"", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.DataExplorerClient.ApiDatasetsTasksMetadataRetrieve.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.DataExplorerClient.ApiDatasetsTasksMetadataRetrieve.g.cs index e142e46..1a2e3b1 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.DataExplorerClient.ApiDatasetsTasksMetadataRetrieve.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.DataExplorerClient.ApiDatasetsTasksMetadataRetrieve.g.cs @@ -14,6 +14,7 @@ public partial class DataExplorerClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -47,12 +48,14 @@ partial void ProcessApiDatasetsTasksMetadataRetrieveResponse( /// /// /// + /// 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 ApiDatasetsTasksMetadataRetrieveAsync( string? candidateTaskId = default, int? dataset = default, string? vectordbId = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -69,27 +72,48 @@ partial void ProcessApiDatasetsTasksMetadataRetrieveResponse( securityRequirements: s_ApiDatasetsTasksMetadataRetrieveSecurityRequirements, operationName: "ApiDatasetsTasksMetadataRetrieveAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/datasets/tasks/metadata", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("candidate_task_id", candidateTaskId) - .AddOptionalParameter("dataset", dataset?.ToString()) - .AddOptionalParameter("vectordb_id", vectordbId) - ; - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/datasets/tasks/metadata", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("candidate_task_id", candidateTaskId) + .AddOptionalParameter("dataset", dataset?.ToString()) + .AddOptionalParameter("vectordb_id", vectordbId) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -99,98 +123,257 @@ partial void ProcessApiDatasetsTasksMetadataRetrieveResponse( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareApiDatasetsTasksMetadataRetrieveRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - candidateTaskId: candidateTaskId, - dataset: dataset, - vectordbId: vectordbId); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareApiDatasetsTasksMetadataRetrieveRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + candidateTaskId: candidateTaskId, + dataset: dataset, + vectordbId: vectordbId); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsTasksMetadataRetrieve", + methodName: "ApiDatasetsTasksMetadataRetrieveAsync", + pathTemplate: "\"/api/datasets/tasks/metadata\"", + 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: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsTasksMetadataRetrieve", + methodName: "ApiDatasetsTasksMetadataRetrieveAsync", + pathTemplate: "\"/api/datasets/tasks/metadata\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiDatasetsTasksMetadataRetrieveResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsTasksMetadataRetrieve", + methodName: "ApiDatasetsTasksMetadataRetrieveAsync", + pathTemplate: "\"/api/datasets/tasks/metadata\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessApiDatasetsTasksMetadataRetrieveResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsTasksMetadataRetrieve", + methodName: "ApiDatasetsTasksMetadataRetrieveAsync", + pathTemplate: "\"/api/datasets/tasks/metadata\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsTasksMetadataRetrieve", + methodName: "ApiDatasetsTasksMetadataRetrieveAsync", + pathTemplate: "\"/api/datasets/tasks/metadata\"", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.DataExplorerClient.ApiDatasetsTasksRetrieve.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.DataExplorerClient.ApiDatasetsTasksRetrieve.g.cs index 95add12..8a89e9a 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.DataExplorerClient.ApiDatasetsTasksRetrieve.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.DataExplorerClient.ApiDatasetsTasksRetrieve.g.cs @@ -14,6 +14,7 @@ public partial class DataExplorerClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -61,6 +62,7 @@ partial void ProcessApiDatasetsTasksRetrieveResponseContent( /// /// /// + /// 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 ApiDatasetsTasksRetrieveAsync( @@ -70,6 +72,7 @@ partial void ProcessApiDatasetsTasksRetrieveResponseContent( int? page = default, int? pageSize = default, int? view = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -89,30 +92,51 @@ partial void ProcessApiDatasetsTasksRetrieveResponseContent( securityRequirements: s_ApiDatasetsTasksRetrieveSecurityRequirements, operationName: "ApiDatasetsTasksRetrieveAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/datasets/tasks", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("dataset", dataset?.ToString()) - .AddOptionalParameter("max_threshold", maxThreshold?.ToString()) - .AddOptionalParameter("min_threshold", minThreshold?.ToString()) - .AddOptionalParameter("page", page?.ToString()) - .AddOptionalParameter("page_size", pageSize?.ToString()) - .AddOptionalParameter("view", view?.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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/datasets/tasks", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("dataset", dataset?.ToString()) + .AddOptionalParameter("max_threshold", maxThreshold?.ToString()) + .AddOptionalParameter("min_threshold", minThreshold?.ToString()) + .AddOptionalParameter("page", page?.ToString()) + .AddOptionalParameter("page_size", pageSize?.ToString()) + .AddOptionalParameter("view", view?.ToString()) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -122,117 +146,276 @@ partial void ProcessApiDatasetsTasksRetrieveResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareApiDatasetsTasksRetrieveRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - dataset: dataset, - maxThreshold: maxThreshold, - minThreshold: minThreshold, - page: page, - pageSize: pageSize, - view: view); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareApiDatasetsTasksRetrieveRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + dataset: dataset, + maxThreshold: maxThreshold, + minThreshold: minThreshold, + page: page, + pageSize: pageSize, + view: view); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiDatasetsTasksRetrieveResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsTasksRetrieve", + methodName: "ApiDatasetsTasksRetrieveAsync", + pathTemplate: "\"/api/datasets/tasks\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsTasksRetrieve", + methodName: "ApiDatasetsTasksRetrieveAsync", + pathTemplate: "\"/api/datasets/tasks\"", + 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); - ProcessApiDatasetsTasksRetrieveResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsTasksRetrieve", + methodName: "ApiDatasetsTasksRetrieveAsync", + pathTemplate: "\"/api/datasets/tasks\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.DatasetView.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.DatasetView.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessApiDatasetsTasksRetrieveResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsTasksRetrieve", + methodName: "ApiDatasetsTasksRetrieveAsync", + pathTemplate: "\"/api/datasets/tasks\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsTasksRetrieve", + methodName: "ApiDatasetsTasksRetrieveAsync", + pathTemplate: "\"/api/datasets/tasks\"", + 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); + ProcessApiDatasetsTasksRetrieveResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.DatasetView.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.DatasetView.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.DataExplorerClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.DataExplorerClient.g.cs index d0baef2..d1aa178 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.DataExplorerClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.DataExplorerClient.g.cs @@ -30,6 +30,9 @@ public sealed partial class DataExplorerClient : global::LabelStudio.IDataExplor #if DEBUG = true; #endif + + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public DataExplorerClient( 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 DataExplorerClient. + /// 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 DataExplorerClient( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::LabelStudio.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::LabelStudio.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/LabelStudio/Generated/LabelStudio.DataManagerClient.ApiDmActionsFormRetrieve.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.DataManagerClient.ApiDmActionsFormRetrieve.g.cs index ba9efaa..fc9315a 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.DataManagerClient.ApiDmActionsFormRetrieve.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.DataManagerClient.ApiDmActionsFormRetrieve.g.cs @@ -14,6 +14,7 @@ public partial class DataManagerClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -48,11 +49,13 @@ partial void ProcessApiDmActionsFormRetrieveResponseContent( ///
/// /// + /// 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 ApiDmActionsFormRetrieveAsync( string actionId, int project, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -68,25 +71,46 @@ partial void ProcessApiDmActionsFormRetrieveResponseContent( securityRequirements: s_ApiDmActionsFormRetrieveSecurityRequirements, operationName: "ApiDmActionsFormRetrieveAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/dm/actions/{actionId}/form/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddRequiredParameter("project", project.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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/dm/actions/{actionId}/form/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddRequiredParameter("project", project.ToString()!) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -96,109 +120,268 @@ partial void ProcessApiDmActionsFormRetrieveResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareApiDmActionsFormRetrieveRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - actionId: actionId, - project: project); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareApiDmActionsFormRetrieveRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + actionId: actionId, + project: project); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiDmActionsFormRetrieveResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDmActionsFormRetrieve", + methodName: "ApiDmActionsFormRetrieveAsync", + pathTemplate: "$\"/api/dm/actions/{actionId}/form/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDmActionsFormRetrieve", + methodName: "ApiDmActionsFormRetrieveAsync", + pathTemplate: "$\"/api/dm/actions/{actionId}/form/\"", + 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); - ProcessApiDmActionsFormRetrieveResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDmActionsFormRetrieve", + methodName: "ApiDmActionsFormRetrieveAsync", + pathTemplate: "$\"/api/dm/actions/{actionId}/form/\"", + 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::LabelStudio.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::LabelStudio.ApiException( - message: __content ?? __response.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); + ProcessApiDmActionsFormRetrieveResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDmActionsFormRetrieve", + methodName: "ApiDmActionsFormRetrieveAsync", + pathTemplate: "$\"/api/dm/actions/{actionId}/form/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDmActionsFormRetrieve", + methodName: "ApiDmActionsFormRetrieveAsync", + pathTemplate: "$\"/api/dm/actions/{actionId}/form/\"", + 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); + ProcessApiDmActionsFormRetrieveResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return __content; + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.DataManagerClient.ApiDmProjectRetrieve.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.DataManagerClient.ApiDmProjectRetrieve.g.cs index 786e06a..81103c4 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.DataManagerClient.ApiDmProjectRetrieve.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.DataManagerClient.ApiDmProjectRetrieve.g.cs @@ -14,6 +14,7 @@ public partial class DataManagerClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -37,9 +38,11 @@ partial void ProcessApiDmProjectRetrieveResponse( /// Get project state
/// Retrieve the project state for the data manager. /// + /// 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 ApiDmProjectRetrieveAsync( + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -53,22 +56,43 @@ partial void ProcessApiDmProjectRetrieveResponse( securityRequirements: s_ApiDmProjectRetrieveSecurityRequirements, operationName: "ApiDmProjectRetrieveAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/dm/project/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/dm/project/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -78,95 +102,254 @@ partial void ProcessApiDmProjectRetrieveResponse( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareApiDmProjectRetrieveRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareApiDmProjectRetrieveRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest); + + return __httpRequest; + } - using var __response = await HttpClient.SendAsync( + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDmProjectRetrieve", + methodName: "ApiDmProjectRetrieveAsync", + pathTemplate: "\"/api/dm/project/\"", + 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: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDmProjectRetrieve", + methodName: "ApiDmProjectRetrieveAsync", + pathTemplate: "\"/api/dm/project/\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiDmProjectRetrieveResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDmProjectRetrieve", + methodName: "ApiDmProjectRetrieveAsync", + pathTemplate: "\"/api/dm/project/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessApiDmProjectRetrieveResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDmProjectRetrieve", + methodName: "ApiDmProjectRetrieveAsync", + pathTemplate: "\"/api/dm/project/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDmProjectRetrieve", + methodName: "ApiDmProjectRetrieveAsync", + pathTemplate: "\"/api/dm/project/\"", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.DataManagerClient.ApiDmViewsUpdate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.DataManagerClient.ApiDmViewsUpdate.g.cs index 882c4b3..ae28662 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.DataManagerClient.ApiDmViewsUpdate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.DataManagerClient.ApiDmViewsUpdate.g.cs @@ -14,6 +14,7 @@ public partial class DataManagerClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -48,12 +49,14 @@ partial void ProcessApiDmViewsUpdateResponseContent( /// /// /// + /// 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 ApiDmViewsUpdateAsync( string id, global::LabelStudio.ApiDmViewsUpdateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -71,22 +74,43 @@ partial void ProcessApiDmViewsUpdateResponseContent( securityRequirements: s_ApiDmViewsUpdateSecurityRequirements, operationName: "ApiDmViewsUpdateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/dm/views/{id}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/dm/views/{id}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -96,119 +120,278 @@ partial void ProcessApiDmViewsUpdateResponseContent( __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); - PrepareApiDmViewsUpdateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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::LabelStudio.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); + PrepareApiDmViewsUpdateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiDmViewsUpdateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDmViewsUpdate", + methodName: "ApiDmViewsUpdateAsync", + pathTemplate: "$\"/api/dm/views/{id}/\"", + 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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDmViewsUpdate", + methodName: "ApiDmViewsUpdateAsync", + pathTemplate: "$\"/api/dm/views/{id}/\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessApiDmViewsUpdateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDmViewsUpdate", + methodName: "ApiDmViewsUpdateAsync", + pathTemplate: "$\"/api/dm/views/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.View.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.View.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessApiDmViewsUpdateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDmViewsUpdate", + methodName: "ApiDmViewsUpdateAsync", + pathTemplate: "$\"/api/dm/views/{id}/\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDmViewsUpdate", + methodName: "ApiDmViewsUpdateAsync", + pathTemplate: "$\"/api/dm/views/{id}/\"", + httpMethod: "PUT", + 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); + ProcessApiDmViewsUpdateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.View.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.View.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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(); + } } /// /// Put view
@@ -221,12 +404,14 @@ partial void ProcessApiDmViewsUpdateResponseContent( /// /// Project ID /// + /// 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 ApiDmViewsUpdateAsync( string id, global::LabelStudio.ApiDmViewsUpdateRequestData? data = default, int? project = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.ApiDmViewsUpdateRequest @@ -238,6 +423,7 @@ partial void ProcessApiDmViewsUpdateResponseContent( return await ApiDmViewsUpdateAsync( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.DataManagerClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.DataManagerClient.g.cs index b96bda9..f77a191 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.DataManagerClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.DataManagerClient.g.cs @@ -30,6 +30,9 @@ public sealed partial class DataManagerClient : global::LabelStudio.IDataManager #if DEBUG = true; #endif + + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public DataManagerClient( 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 DataManagerClient. + /// 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 DataManagerClient( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::LabelStudio.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::LabelStudio.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageAzureClient.ApiDatasetStoragesAzureCheckForRecordsCreate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageAzureClient.ApiDatasetStoragesAzureCheckForRecordsCreate.g.cs index 9e693f6..5261750 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageAzureClient.ApiDatasetStoragesAzureCheckForRecordsCreate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageAzureClient.ApiDatasetStoragesAzureCheckForRecordsCreate.g.cs @@ -14,6 +14,7 @@ public partial class DatasetStorageAzureClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,11 +46,13 @@ partial void ProcessApiDatasetStoragesAzureCheckForRecordsCreateResponseContent( /// Checks for existence of records matching the file pattern in the bucket/prefix ///
/// + /// 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 ApiDatasetStoragesAzureCheckForRecordsCreateAsync( global::LabelStudio.AzureDatasetStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -66,22 +69,43 @@ partial void ProcessApiDatasetStoragesAzureCheckForRecordsCreateResponseContent( securityRequirements: s_ApiDatasetStoragesAzureCheckForRecordsCreateSecurityRequirements, operationName: "ApiDatasetStoragesAzureCheckForRecordsCreateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/dataset-storages/azure/check-for-records/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/dataset-storages/azure/check-for-records/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,118 +115,277 @@ partial void ProcessApiDatasetStoragesAzureCheckForRecordsCreateResponseContent( __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::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareApiDatasetStoragesAzureCheckForRecordsCreateRequest( - 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); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareApiDatasetStoragesAzureCheckForRecordsCreateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiDatasetStoragesAzureCheckForRecordsCreateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesAzureCheckForRecordsCreate", + methodName: "ApiDatasetStoragesAzureCheckForRecordsCreateAsync", + pathTemplate: "\"/api/dataset-storages/azure/check-for-records/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesAzureCheckForRecordsCreate", + methodName: "ApiDatasetStoragesAzureCheckForRecordsCreateAsync", + pathTemplate: "\"/api/dataset-storages/azure/check-for-records/\"", + 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); - ProcessApiDatasetStoragesAzureCheckForRecordsCreateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesAzureCheckForRecordsCreate", + methodName: "ApiDatasetStoragesAzureCheckForRecordsCreateAsync", + pathTemplate: "\"/api/dataset-storages/azure/check-for-records/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.AzureDatasetStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.AzureDatasetStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessApiDatasetStoragesAzureCheckForRecordsCreateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesAzureCheckForRecordsCreate", + methodName: "ApiDatasetStoragesAzureCheckForRecordsCreateAsync", + pathTemplate: "\"/api/dataset-storages/azure/check-for-records/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesAzureCheckForRecordsCreate", + methodName: "ApiDatasetStoragesAzureCheckForRecordsCreateAsync", + pathTemplate: "\"/api/dataset-storages/azure/check-for-records/\"", + 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); + ProcessApiDatasetStoragesAzureCheckForRecordsCreateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.AzureDatasetStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.AzureDatasetStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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(); + } } /// /// Check for records given the file pattern
@@ -276,6 +459,7 @@ partial void ProcessApiDatasetStoragesAzureCheckForRecordsCreateResponseContent( /// /// Interpret objects as BLOBs and generate URLs /// + /// 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 ApiDatasetStoragesAzureCheckForRecordsCreateAsync( @@ -300,6 +484,7 @@ partial void ProcessApiDatasetStoragesAzureCheckForRecordsCreateResponseContent( string? title = default, string? traceback = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.AzureDatasetStorageRequest @@ -329,6 +514,7 @@ partial void ProcessApiDatasetStoragesAzureCheckForRecordsCreateResponseContent( return await ApiDatasetStoragesAzureCheckForRecordsCreateAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageAzureClient.ApiDatasetStoragesAzureColumnsRetrieve.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageAzureClient.ApiDatasetStoragesAzureColumnsRetrieve.g.cs index 1732d3b..45eea91 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageAzureClient.ApiDatasetStoragesAzureColumnsRetrieve.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageAzureClient.ApiDatasetStoragesAzureColumnsRetrieve.g.cs @@ -14,6 +14,7 @@ public partial class DatasetStorageAzureClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -40,10 +41,12 @@ partial void ProcessApiDatasetStoragesAzureColumnsRetrieveResponse( /// Retrieves column names from users JSON/blob data in bucket ///
/// + /// 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 ApiDatasetStoragesAzureColumnsRetrieveAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -58,22 +61,43 @@ partial void ProcessApiDatasetStoragesAzureColumnsRetrieveResponse( securityRequirements: s_ApiDatasetStoragesAzureColumnsRetrieveSecurityRequirements, operationName: "ApiDatasetStoragesAzureColumnsRetrieveAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/dataset-storages/azure/{id}/columns/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/dataset-storages/azure/{id}/columns/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,96 +107,255 @@ partial void ProcessApiDatasetStoragesAzureColumnsRetrieveResponse( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareApiDatasetStoragesAzureColumnsRetrieveRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareApiDatasetStoragesAzureColumnsRetrieveRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesAzureColumnsRetrieve", + methodName: "ApiDatasetStoragesAzureColumnsRetrieveAsync", + pathTemplate: "$\"/api/dataset-storages/azure/{id}/columns/\"", + 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: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesAzureColumnsRetrieve", + methodName: "ApiDatasetStoragesAzureColumnsRetrieveAsync", + pathTemplate: "$\"/api/dataset-storages/azure/{id}/columns/\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiDatasetStoragesAzureColumnsRetrieveResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesAzureColumnsRetrieve", + methodName: "ApiDatasetStoragesAzureColumnsRetrieveAsync", + pathTemplate: "$\"/api/dataset-storages/azure/{id}/columns/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessApiDatasetStoragesAzureColumnsRetrieveResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesAzureColumnsRetrieve", + methodName: "ApiDatasetStoragesAzureColumnsRetrieveAsync", + pathTemplate: "$\"/api/dataset-storages/azure/{id}/columns/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesAzureColumnsRetrieve", + methodName: "ApiDatasetStoragesAzureColumnsRetrieveAsync", + pathTemplate: "$\"/api/dataset-storages/azure/{id}/columns/\"", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.DatasetStorageAzureClient.ApiDatasetStoragesAzureCreate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageAzureClient.ApiDatasetStoragesAzureCreate.g.cs index ef4ba55..ddc46f4 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageAzureClient.ApiDatasetStoragesAzureCreate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageAzureClient.ApiDatasetStoragesAzureCreate.g.cs @@ -14,6 +14,7 @@ public partial class DatasetStorageAzureClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,11 +46,13 @@ partial void ProcessApiDatasetStoragesAzureCreateResponseContent( /// Create a new Azure import storage connection. /// /// + /// 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 ApiDatasetStoragesAzureCreateAsync( global::LabelStudio.AzureDatasetStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -66,22 +69,43 @@ partial void ProcessApiDatasetStoragesAzureCreateResponseContent( securityRequirements: s_ApiDatasetStoragesAzureCreateSecurityRequirements, operationName: "ApiDatasetStoragesAzureCreateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/dataset-storages/azure/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/dataset-storages/azure/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,118 +115,277 @@ partial void ProcessApiDatasetStoragesAzureCreateResponseContent( __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::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareApiDatasetStoragesAzureCreateRequest( - 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); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareApiDatasetStoragesAzureCreateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiDatasetStoragesAzureCreateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesAzureCreate", + methodName: "ApiDatasetStoragesAzureCreateAsync", + pathTemplate: "\"/api/dataset-storages/azure/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesAzureCreate", + methodName: "ApiDatasetStoragesAzureCreateAsync", + pathTemplate: "\"/api/dataset-storages/azure/\"", + 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); - ProcessApiDatasetStoragesAzureCreateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesAzureCreate", + methodName: "ApiDatasetStoragesAzureCreateAsync", + pathTemplate: "\"/api/dataset-storages/azure/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.AzureDatasetStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.AzureDatasetStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessApiDatasetStoragesAzureCreateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesAzureCreate", + methodName: "ApiDatasetStoragesAzureCreateAsync", + pathTemplate: "\"/api/dataset-storages/azure/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesAzureCreate", + methodName: "ApiDatasetStoragesAzureCreateAsync", + pathTemplate: "\"/api/dataset-storages/azure/\"", + 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); + ProcessApiDatasetStoragesAzureCreateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.AzureDatasetStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.AzureDatasetStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 import storage
@@ -276,6 +459,7 @@ partial void ProcessApiDatasetStoragesAzureCreateResponseContent( /// /// Interpret objects as BLOBs and generate URLs /// + /// 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 ApiDatasetStoragesAzureCreateAsync( @@ -300,6 +484,7 @@ partial void ProcessApiDatasetStoragesAzureCreateResponseContent( string? title = default, string? traceback = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.AzureDatasetStorageRequest @@ -329,6 +514,7 @@ partial void ProcessApiDatasetStoragesAzureCreateResponseContent( return await ApiDatasetStoragesAzureCreateAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageAzureClient.ApiDatasetStoragesAzureDestroy.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageAzureClient.ApiDatasetStoragesAzureDestroy.g.cs index 7b917b6..eb692bc 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageAzureClient.ApiDatasetStoragesAzureDestroy.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageAzureClient.ApiDatasetStoragesAzureDestroy.g.cs @@ -14,6 +14,7 @@ public partial class DatasetStorageAzureClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -40,10 +41,12 @@ partial void ProcessApiDatasetStoragesAzureDestroyResponse( /// Delete a specific Azure import storage connection. ///
/// + /// 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 ApiDatasetStoragesAzureDestroyAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -58,22 +61,43 @@ partial void ProcessApiDatasetStoragesAzureDestroyResponse( securityRequirements: s_ApiDatasetStoragesAzureDestroySecurityRequirements, operationName: "ApiDatasetStoragesAzureDestroyAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/dataset-storages/azure/{id}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/dataset-storages/azure/{id}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -83,96 +107,255 @@ partial void ProcessApiDatasetStoragesAzureDestroyResponse( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareApiDatasetStoragesAzureDestroyRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareApiDatasetStoragesAzureDestroyRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesAzureDestroy", + methodName: "ApiDatasetStoragesAzureDestroyAsync", + pathTemplate: "$\"/api/dataset-storages/azure/{id}/\"", + 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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesAzureDestroy", + methodName: "ApiDatasetStoragesAzureDestroyAsync", + pathTemplate: "$\"/api/dataset-storages/azure/{id}/\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiDatasetStoragesAzureDestroyResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesAzureDestroy", + methodName: "ApiDatasetStoragesAzureDestroyAsync", + pathTemplate: "$\"/api/dataset-storages/azure/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessApiDatasetStoragesAzureDestroyResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesAzureDestroy", + methodName: "ApiDatasetStoragesAzureDestroyAsync", + pathTemplate: "$\"/api/dataset-storages/azure/{id}/\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesAzureDestroy", + methodName: "ApiDatasetStoragesAzureDestroyAsync", + pathTemplate: "$\"/api/dataset-storages/azure/{id}/\"", + httpMethod: "DELETE", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.DatasetStorageAzureClient.ApiDatasetStoragesAzureList.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageAzureClient.ApiDatasetStoragesAzureList.g.cs index 034d993..1d1320d 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageAzureClient.ApiDatasetStoragesAzureList.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageAzureClient.ApiDatasetStoragesAzureList.g.cs @@ -14,6 +14,7 @@ public partial class DatasetStorageAzureClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -48,11 +49,13 @@ partial void ProcessApiDatasetStoragesAzureListResponseContent( /// /// /// + /// 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> ApiDatasetStoragesAzureListAsync( int? dataset = default, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -68,26 +71,47 @@ partial void ProcessApiDatasetStoragesAzureListResponseContent( securityRequirements: s_ApiDatasetStoragesAzureListSecurityRequirements, operationName: "ApiDatasetStoragesAzureListAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/dataset-storages/azure/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("dataset", dataset?.ToString()) - .AddOptionalParameter("ordering", ordering) - ; - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/dataset-storages/azure/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("dataset", dataset?.ToString()) + .AddOptionalParameter("ordering", ordering) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -97,113 +121,272 @@ partial void ProcessApiDatasetStoragesAzureListResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareApiDatasetStoragesAzureListRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - dataset: dataset, - ordering: ordering); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareApiDatasetStoragesAzureListRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + dataset: dataset, + ordering: ordering); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiDatasetStoragesAzureListResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesAzureList", + methodName: "ApiDatasetStoragesAzureListAsync", + pathTemplate: "\"/api/dataset-storages/azure/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesAzureList", + methodName: "ApiDatasetStoragesAzureListAsync", + pathTemplate: "\"/api/dataset-storages/azure/\"", + 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); - ProcessApiDatasetStoragesAzureListResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesAzureList", + methodName: "ApiDatasetStoragesAzureListAsync", + pathTemplate: "\"/api/dataset-storages/azure/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessApiDatasetStoragesAzureListResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesAzureList", + methodName: "ApiDatasetStoragesAzureListAsync", + pathTemplate: "\"/api/dataset-storages/azure/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesAzureList", + methodName: "ApiDatasetStoragesAzureListAsync", + pathTemplate: "\"/api/dataset-storages/azure/\"", + 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); + ProcessApiDatasetStoragesAzureListResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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 + (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.DatasetStorageAzureClient.ApiDatasetStoragesAzurePartialUpdate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageAzureClient.ApiDatasetStoragesAzurePartialUpdate.g.cs index fc7b703..6471a76 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageAzureClient.ApiDatasetStoragesAzurePartialUpdate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageAzureClient.ApiDatasetStoragesAzurePartialUpdate.g.cs @@ -14,6 +14,7 @@ public partial class DatasetStorageAzureClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -48,12 +49,14 @@ partial void ProcessApiDatasetStoragesAzurePartialUpdateResponseContent( /// /// /// + /// 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 ApiDatasetStoragesAzurePartialUpdateAsync( int id, global::LabelStudio.PatchedAzureDatasetStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -71,22 +74,43 @@ partial void ProcessApiDatasetStoragesAzurePartialUpdateResponseContent( securityRequirements: s_ApiDatasetStoragesAzurePartialUpdateSecurityRequirements, operationName: "ApiDatasetStoragesAzurePartialUpdateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/dataset-storages/azure/{id}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/dataset-storages/azure/{id}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -96,119 +120,278 @@ partial void ProcessApiDatasetStoragesAzurePartialUpdateResponseContent( __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); - PrepareApiDatasetStoragesAzurePartialUpdateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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::LabelStudio.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); + PrepareApiDatasetStoragesAzurePartialUpdateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiDatasetStoragesAzurePartialUpdateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesAzurePartialUpdate", + methodName: "ApiDatasetStoragesAzurePartialUpdateAsync", + pathTemplate: "$\"/api/dataset-storages/azure/{id}/\"", + 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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesAzurePartialUpdate", + methodName: "ApiDatasetStoragesAzurePartialUpdateAsync", + pathTemplate: "$\"/api/dataset-storages/azure/{id}/\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessApiDatasetStoragesAzurePartialUpdateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesAzurePartialUpdate", + methodName: "ApiDatasetStoragesAzurePartialUpdateAsync", + pathTemplate: "$\"/api/dataset-storages/azure/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.AzureDatasetStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.AzureDatasetStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessApiDatasetStoragesAzurePartialUpdateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesAzurePartialUpdate", + methodName: "ApiDatasetStoragesAzurePartialUpdateAsync", + pathTemplate: "$\"/api/dataset-storages/azure/{id}/\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesAzurePartialUpdate", + methodName: "ApiDatasetStoragesAzurePartialUpdateAsync", + pathTemplate: "$\"/api/dataset-storages/azure/{id}/\"", + httpMethod: "PATCH", + 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); + ProcessApiDatasetStoragesAzurePartialUpdateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.AzureDatasetStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.AzureDatasetStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 import storage
@@ -283,6 +466,7 @@ partial void ProcessApiDatasetStoragesAzurePartialUpdateResponseContent( /// /// Interpret objects as BLOBs and generate URLs /// + /// 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 ApiDatasetStoragesAzurePartialUpdateAsync( @@ -308,6 +492,7 @@ partial void ProcessApiDatasetStoragesAzurePartialUpdateResponseContent( string? title = default, string? traceback = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.PatchedAzureDatasetStorageRequest @@ -338,6 +523,7 @@ partial void ProcessApiDatasetStoragesAzurePartialUpdateResponseContent( return await ApiDatasetStoragesAzurePartialUpdateAsync( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageAzureClient.ApiDatasetStoragesAzureRetrieve.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageAzureClient.ApiDatasetStoragesAzureRetrieve.g.cs index d05e87b..bce3e16 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageAzureClient.ApiDatasetStoragesAzureRetrieve.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageAzureClient.ApiDatasetStoragesAzureRetrieve.g.cs @@ -14,6 +14,7 @@ public partial class DatasetStorageAzureClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,10 +46,12 @@ partial void ProcessApiDatasetStoragesAzureRetrieveResponseContent( /// Get a specific Azure import storage connection. ///
/// + /// 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 ApiDatasetStoragesAzureRetrieveAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -63,22 +66,43 @@ partial void ProcessApiDatasetStoragesAzureRetrieveResponseContent( securityRequirements: s_ApiDatasetStoragesAzureRetrieveSecurityRequirements, operationName: "ApiDatasetStoragesAzureRetrieveAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/dataset-storages/azure/{id}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/dataset-storages/azure/{id}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -88,112 +112,271 @@ partial void ProcessApiDatasetStoragesAzureRetrieveResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareApiDatasetStoragesAzureRetrieveRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareApiDatasetStoragesAzureRetrieveRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiDatasetStoragesAzureRetrieveResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesAzureRetrieve", + methodName: "ApiDatasetStoragesAzureRetrieveAsync", + pathTemplate: "$\"/api/dataset-storages/azure/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesAzureRetrieve", + methodName: "ApiDatasetStoragesAzureRetrieveAsync", + pathTemplate: "$\"/api/dataset-storages/azure/{id}/\"", + 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); - ProcessApiDatasetStoragesAzureRetrieveResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesAzureRetrieve", + methodName: "ApiDatasetStoragesAzureRetrieveAsync", + pathTemplate: "$\"/api/dataset-storages/azure/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.AzureDatasetStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.AzureDatasetStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessApiDatasetStoragesAzureRetrieveResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesAzureRetrieve", + methodName: "ApiDatasetStoragesAzureRetrieveAsync", + pathTemplate: "$\"/api/dataset-storages/azure/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesAzureRetrieve", + methodName: "ApiDatasetStoragesAzureRetrieveAsync", + pathTemplate: "$\"/api/dataset-storages/azure/{id}/\"", + 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); + ProcessApiDatasetStoragesAzureRetrieveResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.AzureDatasetStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.AzureDatasetStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.DatasetStorageAzureClient.ApiDatasetStoragesAzureSyncCreate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageAzureClient.ApiDatasetStoragesAzureSyncCreate.g.cs index e5e0986..b32b772 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageAzureClient.ApiDatasetStoragesAzureSyncCreate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageAzureClient.ApiDatasetStoragesAzureSyncCreate.g.cs @@ -14,6 +14,7 @@ public partial class DatasetStorageAzureClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -48,12 +49,14 @@ partial void ProcessApiDatasetStoragesAzureSyncCreateResponseContent( /// /// /// + /// 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 ApiDatasetStoragesAzureSyncCreateAsync( int id, global::LabelStudio.AzureDatasetStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -71,22 +74,43 @@ partial void ProcessApiDatasetStoragesAzureSyncCreateResponseContent( securityRequirements: s_ApiDatasetStoragesAzureSyncCreateSecurityRequirements, operationName: "ApiDatasetStoragesAzureSyncCreateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/dataset-storages/azure/{id}/sync/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/dataset-storages/azure/{id}/sync/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,119 +120,278 @@ partial void ProcessApiDatasetStoragesAzureSyncCreateResponseContent( __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); - PrepareApiDatasetStoragesAzureSyncCreateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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::LabelStudio.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); + PrepareApiDatasetStoragesAzureSyncCreateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiDatasetStoragesAzureSyncCreateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesAzureSyncCreate", + methodName: "ApiDatasetStoragesAzureSyncCreateAsync", + pathTemplate: "$\"/api/dataset-storages/azure/{id}/sync/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesAzureSyncCreate", + methodName: "ApiDatasetStoragesAzureSyncCreateAsync", + pathTemplate: "$\"/api/dataset-storages/azure/{id}/sync/\"", + 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); - ProcessApiDatasetStoragesAzureSyncCreateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesAzureSyncCreate", + methodName: "ApiDatasetStoragesAzureSyncCreateAsync", + pathTemplate: "$\"/api/dataset-storages/azure/{id}/sync/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.AzureDatasetStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.AzureDatasetStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessApiDatasetStoragesAzureSyncCreateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesAzureSyncCreate", + methodName: "ApiDatasetStoragesAzureSyncCreateAsync", + pathTemplate: "$\"/api/dataset-storages/azure/{id}/sync/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesAzureSyncCreate", + methodName: "ApiDatasetStoragesAzureSyncCreateAsync", + pathTemplate: "$\"/api/dataset-storages/azure/{id}/sync/\"", + 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); + ProcessApiDatasetStoragesAzureSyncCreateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.AzureDatasetStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.AzureDatasetStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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(); + } } /// /// Sync import storage
@@ -283,6 +466,7 @@ partial void ProcessApiDatasetStoragesAzureSyncCreateResponseContent( /// /// Interpret objects as BLOBs and generate URLs /// + /// 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 ApiDatasetStoragesAzureSyncCreateAsync( @@ -308,6 +492,7 @@ partial void ProcessApiDatasetStoragesAzureSyncCreateResponseContent( string? title = default, string? traceback = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.AzureDatasetStorageRequest @@ -338,6 +523,7 @@ partial void ProcessApiDatasetStoragesAzureSyncCreateResponseContent( return await ApiDatasetStoragesAzureSyncCreateAsync( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageAzureClient.ApiDatasetStoragesAzureValidateCreate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageAzureClient.ApiDatasetStoragesAzureValidateCreate.g.cs index 9129ce6..4e9eec3 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageAzureClient.ApiDatasetStoragesAzureValidateCreate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageAzureClient.ApiDatasetStoragesAzureValidateCreate.g.cs @@ -14,6 +14,7 @@ public partial class DatasetStorageAzureClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,11 +46,13 @@ partial void ProcessApiDatasetStoragesAzureValidateCreateResponseContent( /// Validate a specific Azure import storage connection. ///
/// + /// 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 ApiDatasetStoragesAzureValidateCreateAsync( global::LabelStudio.AzureDatasetStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -66,22 +69,43 @@ partial void ProcessApiDatasetStoragesAzureValidateCreateResponseContent( securityRequirements: s_ApiDatasetStoragesAzureValidateCreateSecurityRequirements, operationName: "ApiDatasetStoragesAzureValidateCreateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/dataset-storages/azure/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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/dataset-storages/azure/validate/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,118 +115,277 @@ partial void ProcessApiDatasetStoragesAzureValidateCreateResponseContent( __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::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareApiDatasetStoragesAzureValidateCreateRequest( - 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); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareApiDatasetStoragesAzureValidateCreateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiDatasetStoragesAzureValidateCreateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesAzureValidateCreate", + methodName: "ApiDatasetStoragesAzureValidateCreateAsync", + pathTemplate: "\"/api/dataset-storages/azure/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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesAzureValidateCreate", + methodName: "ApiDatasetStoragesAzureValidateCreateAsync", + pathTemplate: "\"/api/dataset-storages/azure/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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessApiDatasetStoragesAzureValidateCreateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesAzureValidateCreate", + methodName: "ApiDatasetStoragesAzureValidateCreateAsync", + pathTemplate: "\"/api/dataset-storages/azure/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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.AzureDatasetStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.AzureDatasetStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessApiDatasetStoragesAzureValidateCreateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesAzureValidateCreate", + methodName: "ApiDatasetStoragesAzureValidateCreateAsync", + pathTemplate: "\"/api/dataset-storages/azure/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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesAzureValidateCreate", + methodName: "ApiDatasetStoragesAzureValidateCreateAsync", + pathTemplate: "\"/api/dataset-storages/azure/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); + } + + 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); + ProcessApiDatasetStoragesAzureValidateCreateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.AzureDatasetStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.AzureDatasetStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 import storage
@@ -276,6 +459,7 @@ partial void ProcessApiDatasetStoragesAzureValidateCreateResponseContent( /// /// Interpret objects as BLOBs and generate URLs /// + /// 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 ApiDatasetStoragesAzureValidateCreateAsync( @@ -300,6 +484,7 @@ partial void ProcessApiDatasetStoragesAzureValidateCreateResponseContent( string? title = default, string? traceback = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.AzureDatasetStorageRequest @@ -329,6 +514,7 @@ partial void ProcessApiDatasetStoragesAzureValidateCreateResponseContent( return await ApiDatasetStoragesAzureValidateCreateAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageAzureClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageAzureClient.g.cs index 101490b..6e4f1fc 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageAzureClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageAzureClient.g.cs @@ -30,6 +30,9 @@ public sealed partial class DatasetStorageAzureClient : global::LabelStudio.IDat #if DEBUG = true; #endif + + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public DatasetStorageAzureClient( 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 DatasetStorageAzureClient. + /// 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 DatasetStorageAzureClient( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::LabelStudio.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::LabelStudio.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageGcsClient.ApiDatasetStoragesGcsCheckForRecordsCreate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageGcsClient.ApiDatasetStoragesGcsCheckForRecordsCreate.g.cs index 01b1d26..e60d499 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageGcsClient.ApiDatasetStoragesGcsCheckForRecordsCreate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageGcsClient.ApiDatasetStoragesGcsCheckForRecordsCreate.g.cs @@ -14,6 +14,7 @@ public partial class DatasetStorageGcsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,11 +46,13 @@ partial void ProcessApiDatasetStoragesGcsCheckForRecordsCreateResponseContent( /// Checks for existence of records matching the file pattern in the bucket/prefix ///
/// + /// 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 ApiDatasetStoragesGcsCheckForRecordsCreateAsync( global::LabelStudio.GCSDatasetStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -66,22 +69,43 @@ partial void ProcessApiDatasetStoragesGcsCheckForRecordsCreateResponseContent( securityRequirements: s_ApiDatasetStoragesGcsCheckForRecordsCreateSecurityRequirements, operationName: "ApiDatasetStoragesGcsCheckForRecordsCreateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/dataset-storages/gcs/check-for-records/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/dataset-storages/gcs/check-for-records/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,118 +115,277 @@ partial void ProcessApiDatasetStoragesGcsCheckForRecordsCreateResponseContent( __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::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareApiDatasetStoragesGcsCheckForRecordsCreateRequest( - 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); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareApiDatasetStoragesGcsCheckForRecordsCreateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiDatasetStoragesGcsCheckForRecordsCreateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesGcsCheckForRecordsCreate", + methodName: "ApiDatasetStoragesGcsCheckForRecordsCreateAsync", + pathTemplate: "\"/api/dataset-storages/gcs/check-for-records/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesGcsCheckForRecordsCreate", + methodName: "ApiDatasetStoragesGcsCheckForRecordsCreateAsync", + pathTemplate: "\"/api/dataset-storages/gcs/check-for-records/\"", + 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); - ProcessApiDatasetStoragesGcsCheckForRecordsCreateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesGcsCheckForRecordsCreate", + methodName: "ApiDatasetStoragesGcsCheckForRecordsCreateAsync", + pathTemplate: "\"/api/dataset-storages/gcs/check-for-records/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.GCSDatasetStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.GCSDatasetStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessApiDatasetStoragesGcsCheckForRecordsCreateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesGcsCheckForRecordsCreate", + methodName: "ApiDatasetStoragesGcsCheckForRecordsCreateAsync", + pathTemplate: "\"/api/dataset-storages/gcs/check-for-records/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesGcsCheckForRecordsCreate", + methodName: "ApiDatasetStoragesGcsCheckForRecordsCreateAsync", + pathTemplate: "\"/api/dataset-storages/gcs/check-for-records/\"", + 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); + ProcessApiDatasetStoragesGcsCheckForRecordsCreateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.GCSDatasetStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.GCSDatasetStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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(); + } } /// /// Check for records given the file pattern
@@ -276,6 +459,7 @@ partial void ProcessApiDatasetStoragesGcsCheckForRecordsCreateResponseContent( /// /// Interpret objects as BLOBs and generate URLs /// + /// 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 ApiDatasetStoragesGcsCheckForRecordsCreateAsync( @@ -300,6 +484,7 @@ partial void ProcessApiDatasetStoragesGcsCheckForRecordsCreateResponseContent( string? title = default, string? traceback = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.GCSDatasetStorageRequest @@ -329,6 +514,7 @@ partial void ProcessApiDatasetStoragesGcsCheckForRecordsCreateResponseContent( return await ApiDatasetStoragesGcsCheckForRecordsCreateAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageGcsClient.ApiDatasetStoragesGcsColumnsRetrieve.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageGcsClient.ApiDatasetStoragesGcsColumnsRetrieve.g.cs index 3a09b2e..7d1a575 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageGcsClient.ApiDatasetStoragesGcsColumnsRetrieve.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageGcsClient.ApiDatasetStoragesGcsColumnsRetrieve.g.cs @@ -14,6 +14,7 @@ public partial class DatasetStorageGcsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -40,10 +41,12 @@ partial void ProcessApiDatasetStoragesGcsColumnsRetrieveResponse( /// Retrieves column names from users JSON/blob data in bucket ///
/// + /// 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 ApiDatasetStoragesGcsColumnsRetrieveAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -58,22 +61,43 @@ partial void ProcessApiDatasetStoragesGcsColumnsRetrieveResponse( securityRequirements: s_ApiDatasetStoragesGcsColumnsRetrieveSecurityRequirements, operationName: "ApiDatasetStoragesGcsColumnsRetrieveAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/dataset-storages/gcs/{id}/columns/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/dataset-storages/gcs/{id}/columns/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,96 +107,255 @@ partial void ProcessApiDatasetStoragesGcsColumnsRetrieveResponse( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareApiDatasetStoragesGcsColumnsRetrieveRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareApiDatasetStoragesGcsColumnsRetrieveRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesGcsColumnsRetrieve", + methodName: "ApiDatasetStoragesGcsColumnsRetrieveAsync", + pathTemplate: "$\"/api/dataset-storages/gcs/{id}/columns/\"", + 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: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesGcsColumnsRetrieve", + methodName: "ApiDatasetStoragesGcsColumnsRetrieveAsync", + pathTemplate: "$\"/api/dataset-storages/gcs/{id}/columns/\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiDatasetStoragesGcsColumnsRetrieveResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesGcsColumnsRetrieve", + methodName: "ApiDatasetStoragesGcsColumnsRetrieveAsync", + pathTemplate: "$\"/api/dataset-storages/gcs/{id}/columns/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessApiDatasetStoragesGcsColumnsRetrieveResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesGcsColumnsRetrieve", + methodName: "ApiDatasetStoragesGcsColumnsRetrieveAsync", + pathTemplate: "$\"/api/dataset-storages/gcs/{id}/columns/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesGcsColumnsRetrieve", + methodName: "ApiDatasetStoragesGcsColumnsRetrieveAsync", + pathTemplate: "$\"/api/dataset-storages/gcs/{id}/columns/\"", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.DatasetStorageGcsClient.ApiDatasetStoragesGcsCreate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageGcsClient.ApiDatasetStoragesGcsCreate.g.cs index 735689b..dd72c88 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageGcsClient.ApiDatasetStoragesGcsCreate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageGcsClient.ApiDatasetStoragesGcsCreate.g.cs @@ -14,6 +14,7 @@ public partial class DatasetStorageGcsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,11 +46,13 @@ partial void ProcessApiDatasetStoragesGcsCreateResponseContent( /// Create a new GCS import storage connection. /// /// + /// 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 ApiDatasetStoragesGcsCreateAsync( global::LabelStudio.GCSDatasetStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -66,22 +69,43 @@ partial void ProcessApiDatasetStoragesGcsCreateResponseContent( securityRequirements: s_ApiDatasetStoragesGcsCreateSecurityRequirements, operationName: "ApiDatasetStoragesGcsCreateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/dataset-storages/gcs/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/dataset-storages/gcs/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,118 +115,277 @@ partial void ProcessApiDatasetStoragesGcsCreateResponseContent( __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::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareApiDatasetStoragesGcsCreateRequest( - 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); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareApiDatasetStoragesGcsCreateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiDatasetStoragesGcsCreateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesGcsCreate", + methodName: "ApiDatasetStoragesGcsCreateAsync", + pathTemplate: "\"/api/dataset-storages/gcs/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesGcsCreate", + methodName: "ApiDatasetStoragesGcsCreateAsync", + pathTemplate: "\"/api/dataset-storages/gcs/\"", + 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); - ProcessApiDatasetStoragesGcsCreateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesGcsCreate", + methodName: "ApiDatasetStoragesGcsCreateAsync", + pathTemplate: "\"/api/dataset-storages/gcs/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.GCSDatasetStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.GCSDatasetStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessApiDatasetStoragesGcsCreateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesGcsCreate", + methodName: "ApiDatasetStoragesGcsCreateAsync", + pathTemplate: "\"/api/dataset-storages/gcs/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesGcsCreate", + methodName: "ApiDatasetStoragesGcsCreateAsync", + pathTemplate: "\"/api/dataset-storages/gcs/\"", + 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); + ProcessApiDatasetStoragesGcsCreateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.GCSDatasetStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.GCSDatasetStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 import storage
@@ -276,6 +459,7 @@ partial void ProcessApiDatasetStoragesGcsCreateResponseContent( /// /// Interpret objects as BLOBs and generate URLs /// + /// 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 ApiDatasetStoragesGcsCreateAsync( @@ -300,6 +484,7 @@ partial void ProcessApiDatasetStoragesGcsCreateResponseContent( string? title = default, string? traceback = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.GCSDatasetStorageRequest @@ -329,6 +514,7 @@ partial void ProcessApiDatasetStoragesGcsCreateResponseContent( return await ApiDatasetStoragesGcsCreateAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageGcsClient.ApiDatasetStoragesGcsDestroy.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageGcsClient.ApiDatasetStoragesGcsDestroy.g.cs index 969744f..991ca01 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageGcsClient.ApiDatasetStoragesGcsDestroy.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageGcsClient.ApiDatasetStoragesGcsDestroy.g.cs @@ -14,6 +14,7 @@ public partial class DatasetStorageGcsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -40,10 +41,12 @@ partial void ProcessApiDatasetStoragesGcsDestroyResponse( /// Delete a specific GCS import storage connection. ///
/// + /// 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 ApiDatasetStoragesGcsDestroyAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -58,22 +61,43 @@ partial void ProcessApiDatasetStoragesGcsDestroyResponse( securityRequirements: s_ApiDatasetStoragesGcsDestroySecurityRequirements, operationName: "ApiDatasetStoragesGcsDestroyAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/dataset-storages/gcs/{id}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/dataset-storages/gcs/{id}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -83,96 +107,255 @@ partial void ProcessApiDatasetStoragesGcsDestroyResponse( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareApiDatasetStoragesGcsDestroyRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareApiDatasetStoragesGcsDestroyRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesGcsDestroy", + methodName: "ApiDatasetStoragesGcsDestroyAsync", + pathTemplate: "$\"/api/dataset-storages/gcs/{id}/\"", + 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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesGcsDestroy", + methodName: "ApiDatasetStoragesGcsDestroyAsync", + pathTemplate: "$\"/api/dataset-storages/gcs/{id}/\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiDatasetStoragesGcsDestroyResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesGcsDestroy", + methodName: "ApiDatasetStoragesGcsDestroyAsync", + pathTemplate: "$\"/api/dataset-storages/gcs/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessApiDatasetStoragesGcsDestroyResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesGcsDestroy", + methodName: "ApiDatasetStoragesGcsDestroyAsync", + pathTemplate: "$\"/api/dataset-storages/gcs/{id}/\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesGcsDestroy", + methodName: "ApiDatasetStoragesGcsDestroyAsync", + pathTemplate: "$\"/api/dataset-storages/gcs/{id}/\"", + httpMethod: "DELETE", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.DatasetStorageGcsClient.ApiDatasetStoragesGcsList.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageGcsClient.ApiDatasetStoragesGcsList.g.cs index 67ab779..67541cc 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageGcsClient.ApiDatasetStoragesGcsList.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageGcsClient.ApiDatasetStoragesGcsList.g.cs @@ -14,6 +14,7 @@ public partial class DatasetStorageGcsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -48,11 +49,13 @@ partial void ProcessApiDatasetStoragesGcsListResponseContent( /// /// /// + /// 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> ApiDatasetStoragesGcsListAsync( int? dataset = default, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -68,26 +71,47 @@ partial void ProcessApiDatasetStoragesGcsListResponseContent( securityRequirements: s_ApiDatasetStoragesGcsListSecurityRequirements, operationName: "ApiDatasetStoragesGcsListAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/dataset-storages/gcs/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("dataset", dataset?.ToString()) - .AddOptionalParameter("ordering", ordering) - ; - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/dataset-storages/gcs/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("dataset", dataset?.ToString()) + .AddOptionalParameter("ordering", ordering) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -97,113 +121,272 @@ partial void ProcessApiDatasetStoragesGcsListResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareApiDatasetStoragesGcsListRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - dataset: dataset, - ordering: ordering); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareApiDatasetStoragesGcsListRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + dataset: dataset, + ordering: ordering); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiDatasetStoragesGcsListResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesGcsList", + methodName: "ApiDatasetStoragesGcsListAsync", + pathTemplate: "\"/api/dataset-storages/gcs/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesGcsList", + methodName: "ApiDatasetStoragesGcsListAsync", + pathTemplate: "\"/api/dataset-storages/gcs/\"", + 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); - ProcessApiDatasetStoragesGcsListResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesGcsList", + methodName: "ApiDatasetStoragesGcsListAsync", + pathTemplate: "\"/api/dataset-storages/gcs/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessApiDatasetStoragesGcsListResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesGcsList", + methodName: "ApiDatasetStoragesGcsListAsync", + pathTemplate: "\"/api/dataset-storages/gcs/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesGcsList", + methodName: "ApiDatasetStoragesGcsListAsync", + pathTemplate: "\"/api/dataset-storages/gcs/\"", + 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); + ProcessApiDatasetStoragesGcsListResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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 + (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.DatasetStorageGcsClient.ApiDatasetStoragesGcsPartialUpdate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageGcsClient.ApiDatasetStoragesGcsPartialUpdate.g.cs index d80fbec..dd86f93 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageGcsClient.ApiDatasetStoragesGcsPartialUpdate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageGcsClient.ApiDatasetStoragesGcsPartialUpdate.g.cs @@ -14,6 +14,7 @@ public partial class DatasetStorageGcsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -48,12 +49,14 @@ partial void ProcessApiDatasetStoragesGcsPartialUpdateResponseContent( /// /// /// + /// 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 ApiDatasetStoragesGcsPartialUpdateAsync( int id, global::LabelStudio.PatchedGCSDatasetStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -71,22 +74,43 @@ partial void ProcessApiDatasetStoragesGcsPartialUpdateResponseContent( securityRequirements: s_ApiDatasetStoragesGcsPartialUpdateSecurityRequirements, operationName: "ApiDatasetStoragesGcsPartialUpdateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/dataset-storages/gcs/{id}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/dataset-storages/gcs/{id}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -96,119 +120,278 @@ partial void ProcessApiDatasetStoragesGcsPartialUpdateResponseContent( __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); - PrepareApiDatasetStoragesGcsPartialUpdateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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::LabelStudio.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); + PrepareApiDatasetStoragesGcsPartialUpdateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiDatasetStoragesGcsPartialUpdateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesGcsPartialUpdate", + methodName: "ApiDatasetStoragesGcsPartialUpdateAsync", + pathTemplate: "$\"/api/dataset-storages/gcs/{id}/\"", + 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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesGcsPartialUpdate", + methodName: "ApiDatasetStoragesGcsPartialUpdateAsync", + pathTemplate: "$\"/api/dataset-storages/gcs/{id}/\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessApiDatasetStoragesGcsPartialUpdateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesGcsPartialUpdate", + methodName: "ApiDatasetStoragesGcsPartialUpdateAsync", + pathTemplate: "$\"/api/dataset-storages/gcs/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.GCSDatasetStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.GCSDatasetStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessApiDatasetStoragesGcsPartialUpdateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesGcsPartialUpdate", + methodName: "ApiDatasetStoragesGcsPartialUpdateAsync", + pathTemplate: "$\"/api/dataset-storages/gcs/{id}/\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesGcsPartialUpdate", + methodName: "ApiDatasetStoragesGcsPartialUpdateAsync", + pathTemplate: "$\"/api/dataset-storages/gcs/{id}/\"", + httpMethod: "PATCH", + 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); + ProcessApiDatasetStoragesGcsPartialUpdateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.GCSDatasetStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.GCSDatasetStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 import storage
@@ -283,6 +466,7 @@ partial void ProcessApiDatasetStoragesGcsPartialUpdateResponseContent( /// /// Interpret objects as BLOBs and generate URLs /// + /// 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 ApiDatasetStoragesGcsPartialUpdateAsync( @@ -308,6 +492,7 @@ partial void ProcessApiDatasetStoragesGcsPartialUpdateResponseContent( string? title = default, string? traceback = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.PatchedGCSDatasetStorageRequest @@ -338,6 +523,7 @@ partial void ProcessApiDatasetStoragesGcsPartialUpdateResponseContent( return await ApiDatasetStoragesGcsPartialUpdateAsync( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageGcsClient.ApiDatasetStoragesGcsRetrieve.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageGcsClient.ApiDatasetStoragesGcsRetrieve.g.cs index 157a9cd..86d8318 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageGcsClient.ApiDatasetStoragesGcsRetrieve.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageGcsClient.ApiDatasetStoragesGcsRetrieve.g.cs @@ -14,6 +14,7 @@ public partial class DatasetStorageGcsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,10 +46,12 @@ partial void ProcessApiDatasetStoragesGcsRetrieveResponseContent( /// Get a specific GCS import storage connection. ///
/// + /// 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 ApiDatasetStoragesGcsRetrieveAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -63,22 +66,43 @@ partial void ProcessApiDatasetStoragesGcsRetrieveResponseContent( securityRequirements: s_ApiDatasetStoragesGcsRetrieveSecurityRequirements, operationName: "ApiDatasetStoragesGcsRetrieveAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/dataset-storages/gcs/{id}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/dataset-storages/gcs/{id}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -88,112 +112,271 @@ partial void ProcessApiDatasetStoragesGcsRetrieveResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareApiDatasetStoragesGcsRetrieveRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareApiDatasetStoragesGcsRetrieveRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiDatasetStoragesGcsRetrieveResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesGcsRetrieve", + methodName: "ApiDatasetStoragesGcsRetrieveAsync", + pathTemplate: "$\"/api/dataset-storages/gcs/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesGcsRetrieve", + methodName: "ApiDatasetStoragesGcsRetrieveAsync", + pathTemplate: "$\"/api/dataset-storages/gcs/{id}/\"", + 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); - ProcessApiDatasetStoragesGcsRetrieveResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesGcsRetrieve", + methodName: "ApiDatasetStoragesGcsRetrieveAsync", + pathTemplate: "$\"/api/dataset-storages/gcs/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.GCSDatasetStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.GCSDatasetStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessApiDatasetStoragesGcsRetrieveResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesGcsRetrieve", + methodName: "ApiDatasetStoragesGcsRetrieveAsync", + pathTemplate: "$\"/api/dataset-storages/gcs/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesGcsRetrieve", + methodName: "ApiDatasetStoragesGcsRetrieveAsync", + pathTemplate: "$\"/api/dataset-storages/gcs/{id}/\"", + 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); + ProcessApiDatasetStoragesGcsRetrieveResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.GCSDatasetStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.GCSDatasetStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.DatasetStorageGcsClient.ApiDatasetStoragesGcsSyncCreate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageGcsClient.ApiDatasetStoragesGcsSyncCreate.g.cs index 7947648..cf975aa 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageGcsClient.ApiDatasetStoragesGcsSyncCreate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageGcsClient.ApiDatasetStoragesGcsSyncCreate.g.cs @@ -14,6 +14,7 @@ public partial class DatasetStorageGcsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -48,12 +49,14 @@ partial void ProcessApiDatasetStoragesGcsSyncCreateResponseContent( /// /// /// + /// 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 ApiDatasetStoragesGcsSyncCreateAsync( int id, global::LabelStudio.GCSDatasetStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -71,22 +74,43 @@ partial void ProcessApiDatasetStoragesGcsSyncCreateResponseContent( securityRequirements: s_ApiDatasetStoragesGcsSyncCreateSecurityRequirements, operationName: "ApiDatasetStoragesGcsSyncCreateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/dataset-storages/gcs/{id}/sync/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/dataset-storages/gcs/{id}/sync/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,119 +120,278 @@ partial void ProcessApiDatasetStoragesGcsSyncCreateResponseContent( __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); - PrepareApiDatasetStoragesGcsSyncCreateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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::LabelStudio.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); + PrepareApiDatasetStoragesGcsSyncCreateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiDatasetStoragesGcsSyncCreateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesGcsSyncCreate", + methodName: "ApiDatasetStoragesGcsSyncCreateAsync", + pathTemplate: "$\"/api/dataset-storages/gcs/{id}/sync/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesGcsSyncCreate", + methodName: "ApiDatasetStoragesGcsSyncCreateAsync", + pathTemplate: "$\"/api/dataset-storages/gcs/{id}/sync/\"", + 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); - ProcessApiDatasetStoragesGcsSyncCreateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesGcsSyncCreate", + methodName: "ApiDatasetStoragesGcsSyncCreateAsync", + pathTemplate: "$\"/api/dataset-storages/gcs/{id}/sync/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.GCSDatasetStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.GCSDatasetStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessApiDatasetStoragesGcsSyncCreateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesGcsSyncCreate", + methodName: "ApiDatasetStoragesGcsSyncCreateAsync", + pathTemplate: "$\"/api/dataset-storages/gcs/{id}/sync/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesGcsSyncCreate", + methodName: "ApiDatasetStoragesGcsSyncCreateAsync", + pathTemplate: "$\"/api/dataset-storages/gcs/{id}/sync/\"", + 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); + ProcessApiDatasetStoragesGcsSyncCreateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.GCSDatasetStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.GCSDatasetStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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(); + } } /// /// Sync import storage
@@ -283,6 +466,7 @@ partial void ProcessApiDatasetStoragesGcsSyncCreateResponseContent( /// /// Interpret objects as BLOBs and generate URLs /// + /// 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 ApiDatasetStoragesGcsSyncCreateAsync( @@ -308,6 +492,7 @@ partial void ProcessApiDatasetStoragesGcsSyncCreateResponseContent( string? title = default, string? traceback = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.GCSDatasetStorageRequest @@ -338,6 +523,7 @@ partial void ProcessApiDatasetStoragesGcsSyncCreateResponseContent( return await ApiDatasetStoragesGcsSyncCreateAsync( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageGcsClient.ApiDatasetStoragesGcsValidateCreate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageGcsClient.ApiDatasetStoragesGcsValidateCreate.g.cs index 33d74ca..d921e0a 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageGcsClient.ApiDatasetStoragesGcsValidateCreate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageGcsClient.ApiDatasetStoragesGcsValidateCreate.g.cs @@ -14,6 +14,7 @@ public partial class DatasetStorageGcsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,11 +46,13 @@ partial void ProcessApiDatasetStoragesGcsValidateCreateResponseContent( /// Validate a specific GCS import storage connection. ///
/// + /// 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 ApiDatasetStoragesGcsValidateCreateAsync( global::LabelStudio.GCSDatasetStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -66,22 +69,43 @@ partial void ProcessApiDatasetStoragesGcsValidateCreateResponseContent( securityRequirements: s_ApiDatasetStoragesGcsValidateCreateSecurityRequirements, operationName: "ApiDatasetStoragesGcsValidateCreateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/dataset-storages/gcs/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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/dataset-storages/gcs/validate/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,118 +115,277 @@ partial void ProcessApiDatasetStoragesGcsValidateCreateResponseContent( __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::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareApiDatasetStoragesGcsValidateCreateRequest( - 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); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareApiDatasetStoragesGcsValidateCreateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiDatasetStoragesGcsValidateCreateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesGcsValidateCreate", + methodName: "ApiDatasetStoragesGcsValidateCreateAsync", + pathTemplate: "\"/api/dataset-storages/gcs/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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesGcsValidateCreate", + methodName: "ApiDatasetStoragesGcsValidateCreateAsync", + pathTemplate: "\"/api/dataset-storages/gcs/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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessApiDatasetStoragesGcsValidateCreateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesGcsValidateCreate", + methodName: "ApiDatasetStoragesGcsValidateCreateAsync", + pathTemplate: "\"/api/dataset-storages/gcs/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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.GCSDatasetStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.GCSDatasetStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessApiDatasetStoragesGcsValidateCreateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesGcsValidateCreate", + methodName: "ApiDatasetStoragesGcsValidateCreateAsync", + pathTemplate: "\"/api/dataset-storages/gcs/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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesGcsValidateCreate", + methodName: "ApiDatasetStoragesGcsValidateCreateAsync", + pathTemplate: "\"/api/dataset-storages/gcs/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); + } + + 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); + ProcessApiDatasetStoragesGcsValidateCreateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.GCSDatasetStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.GCSDatasetStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 import storage
@@ -276,6 +459,7 @@ partial void ProcessApiDatasetStoragesGcsValidateCreateResponseContent( /// /// Interpret objects as BLOBs and generate URLs /// + /// 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 ApiDatasetStoragesGcsValidateCreateAsync( @@ -300,6 +484,7 @@ partial void ProcessApiDatasetStoragesGcsValidateCreateResponseContent( string? title = default, string? traceback = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.GCSDatasetStorageRequest @@ -329,6 +514,7 @@ partial void ProcessApiDatasetStoragesGcsValidateCreateResponseContent( return await ApiDatasetStoragesGcsValidateCreateAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageGcsClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageGcsClient.g.cs index a80028a..b34e1d2 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageGcsClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageGcsClient.g.cs @@ -30,6 +30,9 @@ public sealed partial class DatasetStorageGcsClient : global::LabelStudio.IDatas #if DEBUG = true; #endif + + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public DatasetStorageGcsClient( 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 DatasetStorageGcsClient. + /// 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 DatasetStorageGcsClient( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::LabelStudio.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::LabelStudio.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageS3Client.ApiDatasetStoragesS3CheckForRecordsCreate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageS3Client.ApiDatasetStoragesS3CheckForRecordsCreate.g.cs index 99d912d..b78c0dd 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageS3Client.ApiDatasetStoragesS3CheckForRecordsCreate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageS3Client.ApiDatasetStoragesS3CheckForRecordsCreate.g.cs @@ -14,6 +14,7 @@ public partial class DatasetStorageS3Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,11 +46,13 @@ partial void ProcessApiDatasetStoragesS3CheckForRecordsCreateResponseContent( /// Checks for existence of records matching the file pattern in the bucket/prefix ///
/// + /// 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 ApiDatasetStoragesS3CheckForRecordsCreateAsync( global::LabelStudio.S3DatasetStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -66,22 +69,43 @@ partial void ProcessApiDatasetStoragesS3CheckForRecordsCreateResponseContent( securityRequirements: s_ApiDatasetStoragesS3CheckForRecordsCreateSecurityRequirements, operationName: "ApiDatasetStoragesS3CheckForRecordsCreateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/dataset-storages/s3/check-for-records/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/dataset-storages/s3/check-for-records/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,118 +115,277 @@ partial void ProcessApiDatasetStoragesS3CheckForRecordsCreateResponseContent( __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::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareApiDatasetStoragesS3CheckForRecordsCreateRequest( - 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); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareApiDatasetStoragesS3CheckForRecordsCreateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiDatasetStoragesS3CheckForRecordsCreateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesS3CheckForRecordsCreate", + methodName: "ApiDatasetStoragesS3CheckForRecordsCreateAsync", + pathTemplate: "\"/api/dataset-storages/s3/check-for-records/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesS3CheckForRecordsCreate", + methodName: "ApiDatasetStoragesS3CheckForRecordsCreateAsync", + pathTemplate: "\"/api/dataset-storages/s3/check-for-records/\"", + 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); - ProcessApiDatasetStoragesS3CheckForRecordsCreateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesS3CheckForRecordsCreate", + methodName: "ApiDatasetStoragesS3CheckForRecordsCreateAsync", + pathTemplate: "\"/api/dataset-storages/s3/check-for-records/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.S3DatasetStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.S3DatasetStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessApiDatasetStoragesS3CheckForRecordsCreateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesS3CheckForRecordsCreate", + methodName: "ApiDatasetStoragesS3CheckForRecordsCreateAsync", + pathTemplate: "\"/api/dataset-storages/s3/check-for-records/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesS3CheckForRecordsCreate", + methodName: "ApiDatasetStoragesS3CheckForRecordsCreateAsync", + pathTemplate: "\"/api/dataset-storages/s3/check-for-records/\"", + 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); + ProcessApiDatasetStoragesS3CheckForRecordsCreateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.S3DatasetStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.S3DatasetStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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(); + } } /// /// Check for records given the file pattern
@@ -288,6 +471,7 @@ partial void ProcessApiDatasetStoragesS3CheckForRecordsCreateResponseContent( /// /// Interpret objects as BLOBs and generate URLs /// + /// 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 ApiDatasetStoragesS3CheckForRecordsCreateAsync( @@ -316,6 +500,7 @@ partial void ProcessApiDatasetStoragesS3CheckForRecordsCreateResponseContent( string? title = default, string? traceback = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.S3DatasetStorageRequest @@ -349,6 +534,7 @@ partial void ProcessApiDatasetStoragesS3CheckForRecordsCreateResponseContent( return await ApiDatasetStoragesS3CheckForRecordsCreateAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageS3Client.ApiDatasetStoragesS3ColumnsRetrieve.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageS3Client.ApiDatasetStoragesS3ColumnsRetrieve.g.cs index 38cf296..8fb97a7 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageS3Client.ApiDatasetStoragesS3ColumnsRetrieve.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageS3Client.ApiDatasetStoragesS3ColumnsRetrieve.g.cs @@ -14,6 +14,7 @@ public partial class DatasetStorageS3Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -40,10 +41,12 @@ partial void ProcessApiDatasetStoragesS3ColumnsRetrieveResponse( /// Retrieves column names from users JSON/blob data in bucket ///
/// + /// 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 ApiDatasetStoragesS3ColumnsRetrieveAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -58,22 +61,43 @@ partial void ProcessApiDatasetStoragesS3ColumnsRetrieveResponse( securityRequirements: s_ApiDatasetStoragesS3ColumnsRetrieveSecurityRequirements, operationName: "ApiDatasetStoragesS3ColumnsRetrieveAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/dataset-storages/s3/{id}/columns/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/dataset-storages/s3/{id}/columns/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,96 +107,255 @@ partial void ProcessApiDatasetStoragesS3ColumnsRetrieveResponse( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareApiDatasetStoragesS3ColumnsRetrieveRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareApiDatasetStoragesS3ColumnsRetrieveRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesS3ColumnsRetrieve", + methodName: "ApiDatasetStoragesS3ColumnsRetrieveAsync", + pathTemplate: "$\"/api/dataset-storages/s3/{id}/columns/\"", + 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: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesS3ColumnsRetrieve", + methodName: "ApiDatasetStoragesS3ColumnsRetrieveAsync", + pathTemplate: "$\"/api/dataset-storages/s3/{id}/columns/\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiDatasetStoragesS3ColumnsRetrieveResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesS3ColumnsRetrieve", + methodName: "ApiDatasetStoragesS3ColumnsRetrieveAsync", + pathTemplate: "$\"/api/dataset-storages/s3/{id}/columns/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessApiDatasetStoragesS3ColumnsRetrieveResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesS3ColumnsRetrieve", + methodName: "ApiDatasetStoragesS3ColumnsRetrieveAsync", + pathTemplate: "$\"/api/dataset-storages/s3/{id}/columns/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesS3ColumnsRetrieve", + methodName: "ApiDatasetStoragesS3ColumnsRetrieveAsync", + pathTemplate: "$\"/api/dataset-storages/s3/{id}/columns/\"", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.DatasetStorageS3Client.ApiDatasetStoragesS3Create.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageS3Client.ApiDatasetStoragesS3Create.g.cs index 2962c3e..7692159 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageS3Client.ApiDatasetStoragesS3Create.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageS3Client.ApiDatasetStoragesS3Create.g.cs @@ -14,6 +14,7 @@ public partial class DatasetStorageS3Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,11 +46,13 @@ partial void ProcessApiDatasetStoragesS3CreateResponseContent( /// Create a new S3 import storage connection. /// /// + /// 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 ApiDatasetStoragesS3CreateAsync( global::LabelStudio.S3DatasetStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -66,22 +69,43 @@ partial void ProcessApiDatasetStoragesS3CreateResponseContent( securityRequirements: s_ApiDatasetStoragesS3CreateSecurityRequirements, operationName: "ApiDatasetStoragesS3CreateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/dataset-storages/s3/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/dataset-storages/s3/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,118 +115,277 @@ partial void ProcessApiDatasetStoragesS3CreateResponseContent( __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::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareApiDatasetStoragesS3CreateRequest( - 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); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareApiDatasetStoragesS3CreateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiDatasetStoragesS3CreateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesS3Create", + methodName: "ApiDatasetStoragesS3CreateAsync", + pathTemplate: "\"/api/dataset-storages/s3/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesS3Create", + methodName: "ApiDatasetStoragesS3CreateAsync", + pathTemplate: "\"/api/dataset-storages/s3/\"", + 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); - ProcessApiDatasetStoragesS3CreateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesS3Create", + methodName: "ApiDatasetStoragesS3CreateAsync", + pathTemplate: "\"/api/dataset-storages/s3/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.S3DatasetStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.S3DatasetStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessApiDatasetStoragesS3CreateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesS3Create", + methodName: "ApiDatasetStoragesS3CreateAsync", + pathTemplate: "\"/api/dataset-storages/s3/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesS3Create", + methodName: "ApiDatasetStoragesS3CreateAsync", + pathTemplate: "\"/api/dataset-storages/s3/\"", + 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); + ProcessApiDatasetStoragesS3CreateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.S3DatasetStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.S3DatasetStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 import storage
@@ -288,6 +471,7 @@ partial void ProcessApiDatasetStoragesS3CreateResponseContent( /// /// Interpret objects as BLOBs and generate URLs /// + /// 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 ApiDatasetStoragesS3CreateAsync( @@ -316,6 +500,7 @@ partial void ProcessApiDatasetStoragesS3CreateResponseContent( string? title = default, string? traceback = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.S3DatasetStorageRequest @@ -349,6 +534,7 @@ partial void ProcessApiDatasetStoragesS3CreateResponseContent( return await ApiDatasetStoragesS3CreateAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageS3Client.ApiDatasetStoragesS3Destroy.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageS3Client.ApiDatasetStoragesS3Destroy.g.cs index 5f7ff6e..89b9e62 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageS3Client.ApiDatasetStoragesS3Destroy.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageS3Client.ApiDatasetStoragesS3Destroy.g.cs @@ -14,6 +14,7 @@ public partial class DatasetStorageS3Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -40,10 +41,12 @@ partial void ProcessApiDatasetStoragesS3DestroyResponse( /// Delete a specific S3 import storage connection. ///
/// + /// 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 ApiDatasetStoragesS3DestroyAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -58,22 +61,43 @@ partial void ProcessApiDatasetStoragesS3DestroyResponse( securityRequirements: s_ApiDatasetStoragesS3DestroySecurityRequirements, operationName: "ApiDatasetStoragesS3DestroyAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/dataset-storages/s3/{id}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/dataset-storages/s3/{id}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -83,96 +107,255 @@ partial void ProcessApiDatasetStoragesS3DestroyResponse( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareApiDatasetStoragesS3DestroyRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareApiDatasetStoragesS3DestroyRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesS3Destroy", + methodName: "ApiDatasetStoragesS3DestroyAsync", + pathTemplate: "$\"/api/dataset-storages/s3/{id}/\"", + 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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesS3Destroy", + methodName: "ApiDatasetStoragesS3DestroyAsync", + pathTemplate: "$\"/api/dataset-storages/s3/{id}/\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiDatasetStoragesS3DestroyResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesS3Destroy", + methodName: "ApiDatasetStoragesS3DestroyAsync", + pathTemplate: "$\"/api/dataset-storages/s3/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessApiDatasetStoragesS3DestroyResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesS3Destroy", + methodName: "ApiDatasetStoragesS3DestroyAsync", + pathTemplate: "$\"/api/dataset-storages/s3/{id}/\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesS3Destroy", + methodName: "ApiDatasetStoragesS3DestroyAsync", + pathTemplate: "$\"/api/dataset-storages/s3/{id}/\"", + httpMethod: "DELETE", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.DatasetStorageS3Client.ApiDatasetStoragesS3List.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageS3Client.ApiDatasetStoragesS3List.g.cs index d048c31..b8f1d2c 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageS3Client.ApiDatasetStoragesS3List.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageS3Client.ApiDatasetStoragesS3List.g.cs @@ -14,6 +14,7 @@ public partial class DatasetStorageS3Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -48,11 +49,13 @@ partial void ProcessApiDatasetStoragesS3ListResponseContent( /// /// /// + /// 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> ApiDatasetStoragesS3ListAsync( int? dataset = default, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -68,26 +71,47 @@ partial void ProcessApiDatasetStoragesS3ListResponseContent( securityRequirements: s_ApiDatasetStoragesS3ListSecurityRequirements, operationName: "ApiDatasetStoragesS3ListAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/dataset-storages/s3/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("dataset", dataset?.ToString()) - .AddOptionalParameter("ordering", ordering) - ; - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/dataset-storages/s3/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("dataset", dataset?.ToString()) + .AddOptionalParameter("ordering", ordering) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -97,113 +121,272 @@ partial void ProcessApiDatasetStoragesS3ListResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareApiDatasetStoragesS3ListRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - dataset: dataset, - ordering: ordering); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareApiDatasetStoragesS3ListRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + dataset: dataset, + ordering: ordering); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiDatasetStoragesS3ListResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesS3List", + methodName: "ApiDatasetStoragesS3ListAsync", + pathTemplate: "\"/api/dataset-storages/s3/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesS3List", + methodName: "ApiDatasetStoragesS3ListAsync", + pathTemplate: "\"/api/dataset-storages/s3/\"", + 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); - ProcessApiDatasetStoragesS3ListResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesS3List", + methodName: "ApiDatasetStoragesS3ListAsync", + pathTemplate: "\"/api/dataset-storages/s3/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessApiDatasetStoragesS3ListResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesS3List", + methodName: "ApiDatasetStoragesS3ListAsync", + pathTemplate: "\"/api/dataset-storages/s3/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesS3List", + methodName: "ApiDatasetStoragesS3ListAsync", + pathTemplate: "\"/api/dataset-storages/s3/\"", + 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); + ProcessApiDatasetStoragesS3ListResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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 + (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.DatasetStorageS3Client.ApiDatasetStoragesS3PartialUpdate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageS3Client.ApiDatasetStoragesS3PartialUpdate.g.cs index d87fac9..3eaf675 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageS3Client.ApiDatasetStoragesS3PartialUpdate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageS3Client.ApiDatasetStoragesS3PartialUpdate.g.cs @@ -14,6 +14,7 @@ public partial class DatasetStorageS3Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -48,12 +49,14 @@ partial void ProcessApiDatasetStoragesS3PartialUpdateResponseContent( /// /// /// + /// 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 ApiDatasetStoragesS3PartialUpdateAsync( int id, global::LabelStudio.PatchedS3DatasetStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -71,22 +74,43 @@ partial void ProcessApiDatasetStoragesS3PartialUpdateResponseContent( securityRequirements: s_ApiDatasetStoragesS3PartialUpdateSecurityRequirements, operationName: "ApiDatasetStoragesS3PartialUpdateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/dataset-storages/s3/{id}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/dataset-storages/s3/{id}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -96,119 +120,278 @@ partial void ProcessApiDatasetStoragesS3PartialUpdateResponseContent( __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); - PrepareApiDatasetStoragesS3PartialUpdateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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::LabelStudio.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); + PrepareApiDatasetStoragesS3PartialUpdateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiDatasetStoragesS3PartialUpdateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesS3PartialUpdate", + methodName: "ApiDatasetStoragesS3PartialUpdateAsync", + pathTemplate: "$\"/api/dataset-storages/s3/{id}/\"", + 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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesS3PartialUpdate", + methodName: "ApiDatasetStoragesS3PartialUpdateAsync", + pathTemplate: "$\"/api/dataset-storages/s3/{id}/\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessApiDatasetStoragesS3PartialUpdateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesS3PartialUpdate", + methodName: "ApiDatasetStoragesS3PartialUpdateAsync", + pathTemplate: "$\"/api/dataset-storages/s3/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.S3DatasetStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.S3DatasetStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessApiDatasetStoragesS3PartialUpdateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesS3PartialUpdate", + methodName: "ApiDatasetStoragesS3PartialUpdateAsync", + pathTemplate: "$\"/api/dataset-storages/s3/{id}/\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesS3PartialUpdate", + methodName: "ApiDatasetStoragesS3PartialUpdateAsync", + pathTemplate: "$\"/api/dataset-storages/s3/{id}/\"", + httpMethod: "PATCH", + 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); + ProcessApiDatasetStoragesS3PartialUpdateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.S3DatasetStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.S3DatasetStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 import storage
@@ -295,6 +478,7 @@ partial void ProcessApiDatasetStoragesS3PartialUpdateResponseContent( /// /// Interpret objects as BLOBs and generate URLs /// + /// 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 ApiDatasetStoragesS3PartialUpdateAsync( @@ -324,6 +508,7 @@ partial void ProcessApiDatasetStoragesS3PartialUpdateResponseContent( string? title = default, string? traceback = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.PatchedS3DatasetStorageRequest @@ -358,6 +543,7 @@ partial void ProcessApiDatasetStoragesS3PartialUpdateResponseContent( return await ApiDatasetStoragesS3PartialUpdateAsync( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageS3Client.ApiDatasetStoragesS3Retrieve.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageS3Client.ApiDatasetStoragesS3Retrieve.g.cs index 791f618..b5defbe 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageS3Client.ApiDatasetStoragesS3Retrieve.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageS3Client.ApiDatasetStoragesS3Retrieve.g.cs @@ -14,6 +14,7 @@ public partial class DatasetStorageS3Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,10 +46,12 @@ partial void ProcessApiDatasetStoragesS3RetrieveResponseContent( /// Get a specific S3 import storage connection. ///
/// + /// 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 ApiDatasetStoragesS3RetrieveAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -63,22 +66,43 @@ partial void ProcessApiDatasetStoragesS3RetrieveResponseContent( securityRequirements: s_ApiDatasetStoragesS3RetrieveSecurityRequirements, operationName: "ApiDatasetStoragesS3RetrieveAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/dataset-storages/s3/{id}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/dataset-storages/s3/{id}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -88,112 +112,271 @@ partial void ProcessApiDatasetStoragesS3RetrieveResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareApiDatasetStoragesS3RetrieveRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareApiDatasetStoragesS3RetrieveRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiDatasetStoragesS3RetrieveResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesS3Retrieve", + methodName: "ApiDatasetStoragesS3RetrieveAsync", + pathTemplate: "$\"/api/dataset-storages/s3/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesS3Retrieve", + methodName: "ApiDatasetStoragesS3RetrieveAsync", + pathTemplate: "$\"/api/dataset-storages/s3/{id}/\"", + 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); - ProcessApiDatasetStoragesS3RetrieveResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesS3Retrieve", + methodName: "ApiDatasetStoragesS3RetrieveAsync", + pathTemplate: "$\"/api/dataset-storages/s3/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.S3DatasetStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.S3DatasetStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessApiDatasetStoragesS3RetrieveResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesS3Retrieve", + methodName: "ApiDatasetStoragesS3RetrieveAsync", + pathTemplate: "$\"/api/dataset-storages/s3/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesS3Retrieve", + methodName: "ApiDatasetStoragesS3RetrieveAsync", + pathTemplate: "$\"/api/dataset-storages/s3/{id}/\"", + 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); + ProcessApiDatasetStoragesS3RetrieveResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.S3DatasetStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.S3DatasetStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.DatasetStorageS3Client.ApiDatasetStoragesS3SyncCreate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageS3Client.ApiDatasetStoragesS3SyncCreate.g.cs index 533b7d8..e16a8d1 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageS3Client.ApiDatasetStoragesS3SyncCreate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageS3Client.ApiDatasetStoragesS3SyncCreate.g.cs @@ -14,6 +14,7 @@ public partial class DatasetStorageS3Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -48,12 +49,14 @@ partial void ProcessApiDatasetStoragesS3SyncCreateResponseContent( /// /// /// + /// 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 ApiDatasetStoragesS3SyncCreateAsync( int id, global::LabelStudio.S3DatasetStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -71,22 +74,43 @@ partial void ProcessApiDatasetStoragesS3SyncCreateResponseContent( securityRequirements: s_ApiDatasetStoragesS3SyncCreateSecurityRequirements, operationName: "ApiDatasetStoragesS3SyncCreateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/dataset-storages/s3/{id}/sync/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/dataset-storages/s3/{id}/sync/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,119 +120,278 @@ partial void ProcessApiDatasetStoragesS3SyncCreateResponseContent( __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); - PrepareApiDatasetStoragesS3SyncCreateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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::LabelStudio.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); + PrepareApiDatasetStoragesS3SyncCreateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiDatasetStoragesS3SyncCreateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesS3SyncCreate", + methodName: "ApiDatasetStoragesS3SyncCreateAsync", + pathTemplate: "$\"/api/dataset-storages/s3/{id}/sync/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesS3SyncCreate", + methodName: "ApiDatasetStoragesS3SyncCreateAsync", + pathTemplate: "$\"/api/dataset-storages/s3/{id}/sync/\"", + 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); - ProcessApiDatasetStoragesS3SyncCreateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesS3SyncCreate", + methodName: "ApiDatasetStoragesS3SyncCreateAsync", + pathTemplate: "$\"/api/dataset-storages/s3/{id}/sync/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.S3DatasetStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.S3DatasetStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessApiDatasetStoragesS3SyncCreateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesS3SyncCreate", + methodName: "ApiDatasetStoragesS3SyncCreateAsync", + pathTemplate: "$\"/api/dataset-storages/s3/{id}/sync/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesS3SyncCreate", + methodName: "ApiDatasetStoragesS3SyncCreateAsync", + pathTemplate: "$\"/api/dataset-storages/s3/{id}/sync/\"", + 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); + ProcessApiDatasetStoragesS3SyncCreateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.S3DatasetStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.S3DatasetStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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(); + } } /// /// Sync import storage
@@ -295,6 +478,7 @@ partial void ProcessApiDatasetStoragesS3SyncCreateResponseContent( /// /// Interpret objects as BLOBs and generate URLs /// + /// 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 ApiDatasetStoragesS3SyncCreateAsync( @@ -324,6 +508,7 @@ partial void ProcessApiDatasetStoragesS3SyncCreateResponseContent( string? title = default, string? traceback = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.S3DatasetStorageRequest @@ -358,6 +543,7 @@ partial void ProcessApiDatasetStoragesS3SyncCreateResponseContent( return await ApiDatasetStoragesS3SyncCreateAsync( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageS3Client.ApiDatasetStoragesS3ValidateCreate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageS3Client.ApiDatasetStoragesS3ValidateCreate.g.cs index 43447ec..e5f8e84 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageS3Client.ApiDatasetStoragesS3ValidateCreate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageS3Client.ApiDatasetStoragesS3ValidateCreate.g.cs @@ -14,6 +14,7 @@ public partial class DatasetStorageS3Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,11 +46,13 @@ partial void ProcessApiDatasetStoragesS3ValidateCreateResponseContent( /// Validate a specific S3 import storage connection. ///
/// + /// 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 ApiDatasetStoragesS3ValidateCreateAsync( global::LabelStudio.S3DatasetStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -66,22 +69,43 @@ partial void ProcessApiDatasetStoragesS3ValidateCreateResponseContent( securityRequirements: s_ApiDatasetStoragesS3ValidateCreateSecurityRequirements, operationName: "ApiDatasetStoragesS3ValidateCreateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/dataset-storages/s3/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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/dataset-storages/s3/validate/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,118 +115,277 @@ partial void ProcessApiDatasetStoragesS3ValidateCreateResponseContent( __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::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareApiDatasetStoragesS3ValidateCreateRequest( - 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); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareApiDatasetStoragesS3ValidateCreateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiDatasetStoragesS3ValidateCreateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesS3ValidateCreate", + methodName: "ApiDatasetStoragesS3ValidateCreateAsync", + pathTemplate: "\"/api/dataset-storages/s3/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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesS3ValidateCreate", + methodName: "ApiDatasetStoragesS3ValidateCreateAsync", + pathTemplate: "\"/api/dataset-storages/s3/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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessApiDatasetStoragesS3ValidateCreateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesS3ValidateCreate", + methodName: "ApiDatasetStoragesS3ValidateCreateAsync", + pathTemplate: "\"/api/dataset-storages/s3/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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.S3DatasetStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.S3DatasetStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessApiDatasetStoragesS3ValidateCreateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesS3ValidateCreate", + methodName: "ApiDatasetStoragesS3ValidateCreateAsync", + pathTemplate: "\"/api/dataset-storages/s3/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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesS3ValidateCreate", + methodName: "ApiDatasetStoragesS3ValidateCreateAsync", + pathTemplate: "\"/api/dataset-storages/s3/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); + } + + 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); + ProcessApiDatasetStoragesS3ValidateCreateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.S3DatasetStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.S3DatasetStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 import storage
@@ -288,6 +471,7 @@ partial void ProcessApiDatasetStoragesS3ValidateCreateResponseContent( /// /// Interpret objects as BLOBs and generate URLs /// + /// 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 ApiDatasetStoragesS3ValidateCreateAsync( @@ -316,6 +500,7 @@ partial void ProcessApiDatasetStoragesS3ValidateCreateResponseContent( string? title = default, string? traceback = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.S3DatasetStorageRequest @@ -349,6 +534,7 @@ partial void ProcessApiDatasetStoragesS3ValidateCreateResponseContent( return await ApiDatasetStoragesS3ValidateCreateAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageS3Client.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageS3Client.g.cs index 78a778a..15954b5 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageS3Client.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.DatasetStorageS3Client.g.cs @@ -30,6 +30,9 @@ public sealed partial class DatasetStorageS3Client : global::LabelStudio.IDatase #if DEBUG = true; #endif + + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public DatasetStorageS3Client( 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 DatasetStorageS3Client. + /// 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 DatasetStorageS3Client( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::LabelStudio.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::LabelStudio.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/LabelStudio/Generated/LabelStudio.DatasetsClient.ApiDatasetsCreate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.DatasetsClient.ApiDatasetsCreate.g.cs index 4288639..ad79f39 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.DatasetsClient.ApiDatasetsCreate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.DatasetsClient.ApiDatasetsCreate.g.cs @@ -14,6 +14,7 @@ public partial class DatasetsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,11 +46,13 @@ partial void ProcessApiDatasetsCreateResponseContent( /// Create a new dataset. ///
/// + /// 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 ApiDatasetsCreateAsync( global::LabelStudio.DatasetRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -66,22 +69,43 @@ partial void ProcessApiDatasetsCreateResponseContent( securityRequirements: s_ApiDatasetsCreateSecurityRequirements, operationName: "ApiDatasetsCreateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/datasets/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/datasets/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,118 +115,277 @@ partial void ProcessApiDatasetsCreateResponseContent( __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::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareApiDatasetsCreateRequest( - 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); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareApiDatasetsCreateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiDatasetsCreateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsCreate", + methodName: "ApiDatasetsCreateAsync", + pathTemplate: "\"/api/datasets/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsCreate", + methodName: "ApiDatasetsCreateAsync", + pathTemplate: "\"/api/datasets/\"", + 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); - ProcessApiDatasetsCreateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsCreate", + methodName: "ApiDatasetsCreateAsync", + pathTemplate: "\"/api/datasets/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.Dataset.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.Dataset.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessApiDatasetsCreateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsCreate", + methodName: "ApiDatasetsCreateAsync", + pathTemplate: "\"/api/datasets/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsCreate", + methodName: "ApiDatasetsCreateAsync", + pathTemplate: "\"/api/datasets/\"", + 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); + ProcessApiDatasetsCreateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.Dataset.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.Dataset.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 dataset
@@ -225,6 +408,7 @@ partial void ProcessApiDatasetsCreateResponseContent( /// /// Dataset name for weaviate 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 ApiDatasetsCreateAsync( @@ -235,6 +419,7 @@ partial void ProcessApiDatasetsCreateResponseContent( int? organization = default, int? totalEntities = default, string? vectorDbDatasetName = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.DatasetRequest @@ -250,6 +435,7 @@ partial void ProcessApiDatasetsCreateResponseContent( return await ApiDatasetsCreateAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.DatasetsClient.ApiDatasetsDestroy.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.DatasetsClient.ApiDatasetsDestroy.g.cs index 6e38a8e..9478483 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.DatasetsClient.ApiDatasetsDestroy.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.DatasetsClient.ApiDatasetsDestroy.g.cs @@ -14,6 +14,7 @@ public partial class DatasetsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -40,10 +41,12 @@ partial void ProcessApiDatasetsDestroyResponse( /// Delete a dataset by ID ///
/// + /// 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 ApiDatasetsDestroyAsync( string id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -58,22 +61,43 @@ partial void ProcessApiDatasetsDestroyResponse( securityRequirements: s_ApiDatasetsDestroySecurityRequirements, operationName: "ApiDatasetsDestroyAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/datasets/{id}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/datasets/{id}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -83,96 +107,255 @@ partial void ProcessApiDatasetsDestroyResponse( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareApiDatasetsDestroyRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareApiDatasetsDestroyRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsDestroy", + methodName: "ApiDatasetsDestroyAsync", + pathTemplate: "$\"/api/datasets/{id}/\"", + 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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsDestroy", + methodName: "ApiDatasetsDestroyAsync", + pathTemplate: "$\"/api/datasets/{id}/\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiDatasetsDestroyResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsDestroy", + methodName: "ApiDatasetsDestroyAsync", + pathTemplate: "$\"/api/datasets/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessApiDatasetsDestroyResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsDestroy", + methodName: "ApiDatasetsDestroyAsync", + pathTemplate: "$\"/api/datasets/{id}/\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsDestroy", + methodName: "ApiDatasetsDestroyAsync", + pathTemplate: "$\"/api/datasets/{id}/\"", + httpMethod: "DELETE", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.DatasetsClient.ApiDatasetsImportPartialUpdate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.DatasetsClient.ApiDatasetsImportPartialUpdate.g.cs index 08dbceb..30836dc 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.DatasetsClient.ApiDatasetsImportPartialUpdate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.DatasetsClient.ApiDatasetsImportPartialUpdate.g.cs @@ -14,6 +14,7 @@ public partial class DatasetsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -43,11 +44,13 @@ partial void ProcessApiDatasetsImportPartialUpdateResponse( /// /// /// + /// 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 ApiDatasetsImportPartialUpdateAsync( int? jobId = default, string? signal = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -63,26 +66,47 @@ partial void ProcessApiDatasetsImportPartialUpdateResponse( securityRequirements: s_ApiDatasetsImportPartialUpdateSecurityRequirements, operationName: "ApiDatasetsImportPartialUpdateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/datasets/import", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("job_id", jobId?.ToString()) - .AddOptionalParameter("signal", signal) - ; - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/datasets/import", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("job_id", jobId?.ToString()) + .AddOptionalParameter("signal", signal) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -92,97 +116,256 @@ partial void ProcessApiDatasetsImportPartialUpdateResponse( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareApiDatasetsImportPartialUpdateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - jobId: jobId, - signal: signal); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareApiDatasetsImportPartialUpdateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + jobId: jobId, + signal: signal); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsImportPartialUpdate", + methodName: "ApiDatasetsImportPartialUpdateAsync", + pathTemplate: "\"/api/datasets/import\"", + 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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsImportPartialUpdate", + methodName: "ApiDatasetsImportPartialUpdateAsync", + pathTemplate: "\"/api/datasets/import\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiDatasetsImportPartialUpdateResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsImportPartialUpdate", + methodName: "ApiDatasetsImportPartialUpdateAsync", + pathTemplate: "\"/api/datasets/import\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessApiDatasetsImportPartialUpdateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsImportPartialUpdate", + methodName: "ApiDatasetsImportPartialUpdateAsync", + pathTemplate: "\"/api/datasets/import\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsImportPartialUpdate", + methodName: "ApiDatasetsImportPartialUpdateAsync", + pathTemplate: "\"/api/datasets/import\"", + httpMethod: "PATCH", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.DatasetsClient.ApiDatasetsList.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.DatasetsClient.ApiDatasetsList.g.cs index 85b3cf9..bb4d824 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.DatasetsClient.ApiDatasetsList.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.DatasetsClient.ApiDatasetsList.g.cs @@ -14,6 +14,7 @@ public partial class DatasetsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,10 +46,12 @@ partial void ProcessApiDatasetsListResponseContent( /// List all datasets. /// /// + /// 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> ApiDatasetsListAsync( string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -63,25 +66,46 @@ partial void ProcessApiDatasetsListResponseContent( securityRequirements: s_ApiDatasetsListSecurityRequirements, operationName: "ApiDatasetsListAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/datasets/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("ordering", ordering) - ; - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/datasets/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("ordering", ordering) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -91,112 +115,271 @@ partial void ProcessApiDatasetsListResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareApiDatasetsListRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - ordering: ordering); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareApiDatasetsListRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + ordering: ordering); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiDatasetsListResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsList", + methodName: "ApiDatasetsListAsync", + pathTemplate: "\"/api/datasets/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsList", + methodName: "ApiDatasetsListAsync", + pathTemplate: "\"/api/datasets/\"", + 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); - ProcessApiDatasetsListResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsList", + methodName: "ApiDatasetsListAsync", + pathTemplate: "\"/api/datasets/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessApiDatasetsListResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsList", + methodName: "ApiDatasetsListAsync", + pathTemplate: "\"/api/datasets/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsList", + methodName: "ApiDatasetsListAsync", + pathTemplate: "\"/api/datasets/\"", + 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); + ProcessApiDatasetsListResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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 + (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.DatasetsClient.ApiDatasetsMembersCreate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.DatasetsClient.ApiDatasetsMembersCreate.g.cs index 5b43937..6c833e1 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.DatasetsClient.ApiDatasetsMembersCreate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.DatasetsClient.ApiDatasetsMembersCreate.g.cs @@ -14,6 +14,7 @@ public partial class DatasetsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -48,12 +49,14 @@ partial void ProcessApiDatasetsMembersCreateResponseContent( /// /// /// + /// 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 ApiDatasetsMembersCreateAsync( int id, global::LabelStudio.DatasetMemberRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -71,22 +74,43 @@ partial void ProcessApiDatasetsMembersCreateResponseContent( securityRequirements: s_ApiDatasetsMembersCreateSecurityRequirements, operationName: "ApiDatasetsMembersCreateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/datasets/{id}/members", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/datasets/{id}/members", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,119 +120,278 @@ partial void ProcessApiDatasetsMembersCreateResponseContent( __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); - PrepareApiDatasetsMembersCreateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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::LabelStudio.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); + PrepareApiDatasetsMembersCreateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiDatasetsMembersCreateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsMembersCreate", + methodName: "ApiDatasetsMembersCreateAsync", + pathTemplate: "$\"/api/datasets/{id}/members\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsMembersCreate", + methodName: "ApiDatasetsMembersCreateAsync", + pathTemplate: "$\"/api/datasets/{id}/members\"", + 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); - ProcessApiDatasetsMembersCreateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsMembersCreate", + methodName: "ApiDatasetsMembersCreateAsync", + pathTemplate: "$\"/api/datasets/{id}/members\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.DatasetMember.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.DatasetMember.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessApiDatasetsMembersCreateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsMembersCreate", + methodName: "ApiDatasetsMembersCreateAsync", + pathTemplate: "$\"/api/datasets/{id}/members\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsMembersCreate", + methodName: "ApiDatasetsMembersCreateAsync", + pathTemplate: "$\"/api/datasets/{id}/members\"", + 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); + ProcessApiDatasetsMembersCreateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.DatasetMember.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.DatasetMember.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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(); + } } /// /// Add dataset member
@@ -216,11 +399,13 @@ partial void ProcessApiDatasetsMembersCreateResponseContent( ///
/// /// + /// 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 ApiDatasetsMembersCreateAsync( int id, int user, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.DatasetMemberRequest @@ -231,6 +416,7 @@ partial void ProcessApiDatasetsMembersCreateResponseContent( return await ApiDatasetsMembersCreateAsync( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.DatasetsClient.ApiDatasetsMembersDestroy.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.DatasetsClient.ApiDatasetsMembersDestroy.g.cs index 9ccb304..806eec5 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.DatasetsClient.ApiDatasetsMembersDestroy.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.DatasetsClient.ApiDatasetsMembersDestroy.g.cs @@ -14,6 +14,7 @@ public partial class DatasetsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -43,11 +44,13 @@ partial void ProcessApiDatasetsMembersDestroyResponse( /// /// /// + /// 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 ApiDatasetsMembersDestroyAsync( int id, int? projectMember = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -63,25 +66,46 @@ partial void ProcessApiDatasetsMembersDestroyResponse( securityRequirements: s_ApiDatasetsMembersDestroySecurityRequirements, operationName: "ApiDatasetsMembersDestroyAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/datasets/{id}/members", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("project_member", projectMember?.ToString()) - ; - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/datasets/{id}/members", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("project_member", projectMember?.ToString()) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -91,97 +115,256 @@ partial void ProcessApiDatasetsMembersDestroyResponse( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareApiDatasetsMembersDestroyRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - projectMember: projectMember); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareApiDatasetsMembersDestroyRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + projectMember: projectMember); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsMembersDestroy", + methodName: "ApiDatasetsMembersDestroyAsync", + pathTemplate: "$\"/api/datasets/{id}/members\"", + 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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsMembersDestroy", + methodName: "ApiDatasetsMembersDestroyAsync", + pathTemplate: "$\"/api/datasets/{id}/members\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiDatasetsMembersDestroyResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsMembersDestroy", + methodName: "ApiDatasetsMembersDestroyAsync", + pathTemplate: "$\"/api/datasets/{id}/members\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessApiDatasetsMembersDestroyResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsMembersDestroy", + methodName: "ApiDatasetsMembersDestroyAsync", + pathTemplate: "$\"/api/datasets/{id}/members\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsMembersDestroy", + methodName: "ApiDatasetsMembersDestroyAsync", + pathTemplate: "$\"/api/datasets/{id}/members\"", + httpMethod: "DELETE", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.DatasetsClient.ApiDatasetsMembersList.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.DatasetsClient.ApiDatasetsMembersList.g.cs index d8402bf..82bc1e7 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.DatasetsClient.ApiDatasetsMembersList.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.DatasetsClient.ApiDatasetsMembersList.g.cs @@ -14,6 +14,7 @@ public partial class DatasetsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -48,11 +49,13 @@ partial void ProcessApiDatasetsMembersListResponseContent( /// /// /// + /// 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> ApiDatasetsMembersListAsync( int id, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -68,25 +71,46 @@ partial void ProcessApiDatasetsMembersListResponseContent( securityRequirements: s_ApiDatasetsMembersListSecurityRequirements, operationName: "ApiDatasetsMembersListAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/datasets/{id}/members", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("ordering", ordering) - ; - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/datasets/{id}/members", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("ordering", ordering) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -96,113 +120,272 @@ partial void ProcessApiDatasetsMembersListResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareApiDatasetsMembersListRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - ordering: ordering); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareApiDatasetsMembersListRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + ordering: ordering); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiDatasetsMembersListResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsMembersList", + methodName: "ApiDatasetsMembersListAsync", + pathTemplate: "$\"/api/datasets/{id}/members\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsMembersList", + methodName: "ApiDatasetsMembersListAsync", + pathTemplate: "$\"/api/datasets/{id}/members\"", + 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); - ProcessApiDatasetsMembersListResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsMembersList", + methodName: "ApiDatasetsMembersListAsync", + pathTemplate: "$\"/api/datasets/{id}/members\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessApiDatasetsMembersListResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsMembersList", + methodName: "ApiDatasetsMembersListAsync", + pathTemplate: "$\"/api/datasets/{id}/members\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsMembersList", + methodName: "ApiDatasetsMembersListAsync", + pathTemplate: "$\"/api/datasets/{id}/members\"", + 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); + ProcessApiDatasetsMembersListResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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 + (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.DatasetsClient.ApiDatasetsPartialUpdate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.DatasetsClient.ApiDatasetsPartialUpdate.g.cs index 0f91548..b0f1a90 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.DatasetsClient.ApiDatasetsPartialUpdate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.DatasetsClient.ApiDatasetsPartialUpdate.g.cs @@ -14,6 +14,7 @@ public partial class DatasetsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -48,12 +49,14 @@ partial void ProcessApiDatasetsPartialUpdateResponseContent( /// /// /// + /// 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 ApiDatasetsPartialUpdateAsync( string id, global::LabelStudio.PatchedDatasetRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -71,22 +74,43 @@ partial void ProcessApiDatasetsPartialUpdateResponseContent( securityRequirements: s_ApiDatasetsPartialUpdateSecurityRequirements, operationName: "ApiDatasetsPartialUpdateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/datasets/{id}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/datasets/{id}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -96,119 +120,278 @@ partial void ProcessApiDatasetsPartialUpdateResponseContent( __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); - PrepareApiDatasetsPartialUpdateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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::LabelStudio.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); + PrepareApiDatasetsPartialUpdateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiDatasetsPartialUpdateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsPartialUpdate", + methodName: "ApiDatasetsPartialUpdateAsync", + pathTemplate: "$\"/api/datasets/{id}/\"", + 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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsPartialUpdate", + methodName: "ApiDatasetsPartialUpdateAsync", + pathTemplate: "$\"/api/datasets/{id}/\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessApiDatasetsPartialUpdateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsPartialUpdate", + methodName: "ApiDatasetsPartialUpdateAsync", + pathTemplate: "$\"/api/datasets/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.Dataset.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.Dataset.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessApiDatasetsPartialUpdateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsPartialUpdate", + methodName: "ApiDatasetsPartialUpdateAsync", + pathTemplate: "$\"/api/datasets/{id}/\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsPartialUpdate", + methodName: "ApiDatasetsPartialUpdateAsync", + pathTemplate: "$\"/api/datasets/{id}/\"", + httpMethod: "PATCH", + 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); + ProcessApiDatasetsPartialUpdateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.Dataset.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.Dataset.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 dataset
@@ -232,6 +415,7 @@ partial void ProcessApiDatasetsPartialUpdateResponseContent( /// /// Dataset name for weaviate 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 ApiDatasetsPartialUpdateAsync( @@ -243,6 +427,7 @@ partial void ProcessApiDatasetsPartialUpdateResponseContent( string? title = default, int? totalEntities = default, string? vectorDbDatasetName = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.PatchedDatasetRequest @@ -259,6 +444,7 @@ partial void ProcessApiDatasetsPartialUpdateResponseContent( return await ApiDatasetsPartialUpdateAsync( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.DatasetsClient.ApiDatasetsRetrieve.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.DatasetsClient.ApiDatasetsRetrieve.g.cs index 879b766..63b5cfa 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.DatasetsClient.ApiDatasetsRetrieve.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.DatasetsClient.ApiDatasetsRetrieve.g.cs @@ -14,6 +14,7 @@ public partial class DatasetsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,10 +46,12 @@ partial void ProcessApiDatasetsRetrieveResponseContent( /// Retrieve a specific dataset. ///
/// + /// 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 ApiDatasetsRetrieveAsync( string id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -63,22 +66,43 @@ partial void ProcessApiDatasetsRetrieveResponseContent( securityRequirements: s_ApiDatasetsRetrieveSecurityRequirements, operationName: "ApiDatasetsRetrieveAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/datasets/{id}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/datasets/{id}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -88,112 +112,271 @@ partial void ProcessApiDatasetsRetrieveResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareApiDatasetsRetrieveRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareApiDatasetsRetrieveRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiDatasetsRetrieveResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsRetrieve", + methodName: "ApiDatasetsRetrieveAsync", + pathTemplate: "$\"/api/datasets/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsRetrieve", + methodName: "ApiDatasetsRetrieveAsync", + pathTemplate: "$\"/api/datasets/{id}/\"", + 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); - ProcessApiDatasetsRetrieveResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsRetrieve", + methodName: "ApiDatasetsRetrieveAsync", + pathTemplate: "$\"/api/datasets/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.Dataset.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.Dataset.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessApiDatasetsRetrieveResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsRetrieve", + methodName: "ApiDatasetsRetrieveAsync", + pathTemplate: "$\"/api/datasets/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsRetrieve", + methodName: "ApiDatasetsRetrieveAsync", + pathTemplate: "$\"/api/datasets/{id}/\"", + 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); + ProcessApiDatasetsRetrieveResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.Dataset.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.Dataset.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.DatasetsClient.ApiDatasetsUpdate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.DatasetsClient.ApiDatasetsUpdate.g.cs index 489abd0..01c1cd9 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.DatasetsClient.ApiDatasetsUpdate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.DatasetsClient.ApiDatasetsUpdate.g.cs @@ -14,6 +14,7 @@ public partial class DatasetsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -48,12 +49,14 @@ partial void ProcessApiDatasetsUpdateResponseContent( /// /// /// + /// 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 ApiDatasetsUpdateAsync( string id, global::LabelStudio.DatasetRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -71,22 +74,43 @@ partial void ProcessApiDatasetsUpdateResponseContent( securityRequirements: s_ApiDatasetsUpdateSecurityRequirements, operationName: "ApiDatasetsUpdateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/datasets/{id}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/datasets/{id}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -96,119 +120,278 @@ partial void ProcessApiDatasetsUpdateResponseContent( __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); - PrepareApiDatasetsUpdateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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::LabelStudio.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); + PrepareApiDatasetsUpdateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiDatasetsUpdateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsUpdate", + methodName: "ApiDatasetsUpdateAsync", + pathTemplate: "$\"/api/datasets/{id}/\"", + 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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsUpdate", + methodName: "ApiDatasetsUpdateAsync", + pathTemplate: "$\"/api/datasets/{id}/\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessApiDatasetsUpdateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsUpdate", + methodName: "ApiDatasetsUpdateAsync", + pathTemplate: "$\"/api/datasets/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.Dataset.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.Dataset.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessApiDatasetsUpdateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsUpdate", + methodName: "ApiDatasetsUpdateAsync", + pathTemplate: "$\"/api/datasets/{id}/\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsUpdate", + methodName: "ApiDatasetsUpdateAsync", + pathTemplate: "$\"/api/datasets/{id}/\"", + httpMethod: "PUT", + 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); + ProcessApiDatasetsUpdateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.Dataset.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.Dataset.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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(); + } } /// /// Put dataset
@@ -232,6 +415,7 @@ partial void ProcessApiDatasetsUpdateResponseContent( /// /// Dataset name for weaviate 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 ApiDatasetsUpdateAsync( @@ -243,6 +427,7 @@ partial void ProcessApiDatasetsUpdateResponseContent( int? organization = default, int? totalEntities = default, string? vectorDbDatasetName = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.DatasetRequest @@ -259,6 +444,7 @@ partial void ProcessApiDatasetsUpdateResponseContent( return await ApiDatasetsUpdateAsync( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.DatasetsClient.ApiDatasetsViewsCreate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.DatasetsClient.ApiDatasetsViewsCreate.g.cs index 4a4be95..b0d8473 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.DatasetsClient.ApiDatasetsViewsCreate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.DatasetsClient.ApiDatasetsViewsCreate.g.cs @@ -14,6 +14,7 @@ public partial class DatasetsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,11 +46,13 @@ partial void ProcessApiDatasetsViewsCreateResponseContent( /// Create a view for a specific dataset. ///
/// + /// 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 ApiDatasetsViewsCreateAsync( global::LabelStudio.DatasetViewRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -66,22 +69,43 @@ partial void ProcessApiDatasetsViewsCreateResponseContent( securityRequirements: s_ApiDatasetsViewsCreateSecurityRequirements, operationName: "ApiDatasetsViewsCreateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/datasets/views/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/datasets/views/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,118 +115,277 @@ partial void ProcessApiDatasetsViewsCreateResponseContent( __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::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareApiDatasetsViewsCreateRequest( - 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); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareApiDatasetsViewsCreateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiDatasetsViewsCreateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsViewsCreate", + methodName: "ApiDatasetsViewsCreateAsync", + pathTemplate: "\"/api/datasets/views/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsViewsCreate", + methodName: "ApiDatasetsViewsCreateAsync", + pathTemplate: "\"/api/datasets/views/\"", + 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); - ProcessApiDatasetsViewsCreateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsViewsCreate", + methodName: "ApiDatasetsViewsCreateAsync", + pathTemplate: "\"/api/datasets/views/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.DatasetView.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.DatasetView.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessApiDatasetsViewsCreateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsViewsCreate", + methodName: "ApiDatasetsViewsCreateAsync", + pathTemplate: "\"/api/datasets/views/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsViewsCreate", + methodName: "ApiDatasetsViewsCreateAsync", + pathTemplate: "\"/api/datasets/views/\"", + 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); + ProcessApiDatasetsViewsCreateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.DatasetView.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.DatasetView.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 dataset view
@@ -227,6 +410,7 @@ partial void ProcessApiDatasetsViewsCreateResponseContent( /// /// User who made this view /// + /// 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 ApiDatasetsViewsCreateAsync( @@ -237,6 +421,7 @@ partial void ProcessApiDatasetsViewsCreateResponseContent( object? ordering = default, object? selectedItems = default, int? user = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.DatasetViewRequest @@ -252,6 +437,7 @@ partial void ProcessApiDatasetsViewsCreateResponseContent( return await ApiDatasetsViewsCreateAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.DatasetsClient.ApiDatasetsViewsDestroy.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.DatasetsClient.ApiDatasetsViewsDestroy.g.cs index a4a8e1f..679b84a 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.DatasetsClient.ApiDatasetsViewsDestroy.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.DatasetsClient.ApiDatasetsViewsDestroy.g.cs @@ -14,6 +14,7 @@ public partial class DatasetsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -40,10 +41,12 @@ partial void ProcessApiDatasetsViewsDestroyResponse( /// Delete a specific view by ID. ///
/// + /// 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 ApiDatasetsViewsDestroyAsync( string id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -58,22 +61,43 @@ partial void ProcessApiDatasetsViewsDestroyResponse( securityRequirements: s_ApiDatasetsViewsDestroySecurityRequirements, operationName: "ApiDatasetsViewsDestroyAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/datasets/views/{id}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/datasets/views/{id}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -83,96 +107,255 @@ partial void ProcessApiDatasetsViewsDestroyResponse( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareApiDatasetsViewsDestroyRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareApiDatasetsViewsDestroyRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsViewsDestroy", + methodName: "ApiDatasetsViewsDestroyAsync", + pathTemplate: "$\"/api/datasets/views/{id}/\"", + 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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsViewsDestroy", + methodName: "ApiDatasetsViewsDestroyAsync", + pathTemplate: "$\"/api/datasets/views/{id}/\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiDatasetsViewsDestroyResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsViewsDestroy", + methodName: "ApiDatasetsViewsDestroyAsync", + pathTemplate: "$\"/api/datasets/views/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessApiDatasetsViewsDestroyResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsViewsDestroy", + methodName: "ApiDatasetsViewsDestroyAsync", + pathTemplate: "$\"/api/datasets/views/{id}/\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsViewsDestroy", + methodName: "ApiDatasetsViewsDestroyAsync", + pathTemplate: "$\"/api/datasets/views/{id}/\"", + httpMethod: "DELETE", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.DatasetsClient.ApiDatasetsViewsList.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.DatasetsClient.ApiDatasetsViewsList.g.cs index 5dacd3a..f569968 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.DatasetsClient.ApiDatasetsViewsList.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.DatasetsClient.ApiDatasetsViewsList.g.cs @@ -14,6 +14,7 @@ public partial class DatasetsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,10 +46,12 @@ partial void ProcessApiDatasetsViewsListResponseContent( /// List all views for a specific dataset. /// /// + /// 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> ApiDatasetsViewsListAsync( int? dataset = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -63,25 +66,46 @@ partial void ProcessApiDatasetsViewsListResponseContent( securityRequirements: s_ApiDatasetsViewsListSecurityRequirements, operationName: "ApiDatasetsViewsListAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/datasets/views/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("dataset", dataset?.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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/datasets/views/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("dataset", dataset?.ToString()) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -91,112 +115,271 @@ partial void ProcessApiDatasetsViewsListResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareApiDatasetsViewsListRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - dataset: dataset); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareApiDatasetsViewsListRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + dataset: dataset); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiDatasetsViewsListResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsViewsList", + methodName: "ApiDatasetsViewsListAsync", + pathTemplate: "\"/api/datasets/views/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsViewsList", + methodName: "ApiDatasetsViewsListAsync", + pathTemplate: "\"/api/datasets/views/\"", + 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); - ProcessApiDatasetsViewsListResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsViewsList", + methodName: "ApiDatasetsViewsListAsync", + pathTemplate: "\"/api/datasets/views/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessApiDatasetsViewsListResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsViewsList", + methodName: "ApiDatasetsViewsListAsync", + pathTemplate: "\"/api/datasets/views/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsViewsList", + methodName: "ApiDatasetsViewsListAsync", + pathTemplate: "\"/api/datasets/views/\"", + 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); + ProcessApiDatasetsViewsListResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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 + (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.DatasetsClient.ApiDatasetsViewsPartialUpdate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.DatasetsClient.ApiDatasetsViewsPartialUpdate.g.cs index 667f3dc..2885b28 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.DatasetsClient.ApiDatasetsViewsPartialUpdate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.DatasetsClient.ApiDatasetsViewsPartialUpdate.g.cs @@ -14,6 +14,7 @@ public partial class DatasetsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -48,12 +49,14 @@ partial void ProcessApiDatasetsViewsPartialUpdateResponseContent( /// /// /// + /// 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 ApiDatasetsViewsPartialUpdateAsync( string id, global::LabelStudio.PatchedDatasetViewRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -71,22 +74,43 @@ partial void ProcessApiDatasetsViewsPartialUpdateResponseContent( securityRequirements: s_ApiDatasetsViewsPartialUpdateSecurityRequirements, operationName: "ApiDatasetsViewsPartialUpdateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/datasets/views/{id}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/datasets/views/{id}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -96,119 +120,278 @@ partial void ProcessApiDatasetsViewsPartialUpdateResponseContent( __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); - PrepareApiDatasetsViewsPartialUpdateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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::LabelStudio.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); + PrepareApiDatasetsViewsPartialUpdateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiDatasetsViewsPartialUpdateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsViewsPartialUpdate", + methodName: "ApiDatasetsViewsPartialUpdateAsync", + pathTemplate: "$\"/api/datasets/views/{id}/\"", + 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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsViewsPartialUpdate", + methodName: "ApiDatasetsViewsPartialUpdateAsync", + pathTemplate: "$\"/api/datasets/views/{id}/\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessApiDatasetsViewsPartialUpdateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsViewsPartialUpdate", + methodName: "ApiDatasetsViewsPartialUpdateAsync", + pathTemplate: "$\"/api/datasets/views/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.DatasetView.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.DatasetView.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessApiDatasetsViewsPartialUpdateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsViewsPartialUpdate", + methodName: "ApiDatasetsViewsPartialUpdateAsync", + pathTemplate: "$\"/api/datasets/views/{id}/\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsViewsPartialUpdate", + methodName: "ApiDatasetsViewsPartialUpdateAsync", + pathTemplate: "$\"/api/datasets/views/{id}/\"", + httpMethod: "PATCH", + 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); + ProcessApiDatasetsViewsPartialUpdateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.DatasetView.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.DatasetView.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 dataset view
@@ -234,6 +417,7 @@ partial void ProcessApiDatasetsViewsPartialUpdateResponseContent( /// /// User who made this view /// + /// 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 ApiDatasetsViewsPartialUpdateAsync( @@ -245,6 +429,7 @@ partial void ProcessApiDatasetsViewsPartialUpdateResponseContent( object? ordering = default, object? selectedItems = default, int? user = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.PatchedDatasetViewRequest @@ -261,6 +446,7 @@ partial void ProcessApiDatasetsViewsPartialUpdateResponseContent( return await ApiDatasetsViewsPartialUpdateAsync( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.DatasetsClient.ApiDatasetsViewsResetDestroy.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.DatasetsClient.ApiDatasetsViewsResetDestroy.g.cs index ef02f24..1f928e8 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.DatasetsClient.ApiDatasetsViewsResetDestroy.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.DatasetsClient.ApiDatasetsViewsResetDestroy.g.cs @@ -14,6 +14,7 @@ public partial class DatasetsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -37,9 +38,11 @@ partial void ProcessApiDatasetsViewsResetDestroyResponse( /// Reset dataset views
/// Reset all views for a specific dataset. ///
+ /// 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 ApiDatasetsViewsResetDestroyAsync( + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -53,22 +56,43 @@ partial void ProcessApiDatasetsViewsResetDestroyResponse( securityRequirements: s_ApiDatasetsViewsResetDestroySecurityRequirements, operationName: "ApiDatasetsViewsResetDestroyAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/datasets/views/reset/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/datasets/views/reset/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -78,95 +102,254 @@ partial void ProcessApiDatasetsViewsResetDestroyResponse( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareApiDatasetsViewsResetDestroyRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareApiDatasetsViewsResetDestroyRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest); + + return __httpRequest; + } - using var __response = await HttpClient.SendAsync( + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsViewsResetDestroy", + methodName: "ApiDatasetsViewsResetDestroyAsync", + pathTemplate: "\"/api/datasets/views/reset/\"", + 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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsViewsResetDestroy", + methodName: "ApiDatasetsViewsResetDestroyAsync", + pathTemplate: "\"/api/datasets/views/reset/\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiDatasetsViewsResetDestroyResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsViewsResetDestroy", + methodName: "ApiDatasetsViewsResetDestroyAsync", + pathTemplate: "\"/api/datasets/views/reset/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessApiDatasetsViewsResetDestroyResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsViewsResetDestroy", + methodName: "ApiDatasetsViewsResetDestroyAsync", + pathTemplate: "\"/api/datasets/views/reset/\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsViewsResetDestroy", + methodName: "ApiDatasetsViewsResetDestroyAsync", + pathTemplate: "\"/api/datasets/views/reset/\"", + httpMethod: "DELETE", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.DatasetsClient.ApiDatasetsViewsRetrieve.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.DatasetsClient.ApiDatasetsViewsRetrieve.g.cs index 795da73..4fea3ac 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.DatasetsClient.ApiDatasetsViewsRetrieve.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.DatasetsClient.ApiDatasetsViewsRetrieve.g.cs @@ -14,6 +14,7 @@ public partial class DatasetsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,10 +46,12 @@ partial void ProcessApiDatasetsViewsRetrieveResponseContent( /// Get the details about a specific view in the data manager /// /// + /// 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 ApiDatasetsViewsRetrieveAsync( string id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -63,22 +66,43 @@ partial void ProcessApiDatasetsViewsRetrieveResponseContent( securityRequirements: s_ApiDatasetsViewsRetrieveSecurityRequirements, operationName: "ApiDatasetsViewsRetrieveAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/datasets/views/{id}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/datasets/views/{id}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -88,112 +112,271 @@ partial void ProcessApiDatasetsViewsRetrieveResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareApiDatasetsViewsRetrieveRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareApiDatasetsViewsRetrieveRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiDatasetsViewsRetrieveResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsViewsRetrieve", + methodName: "ApiDatasetsViewsRetrieveAsync", + pathTemplate: "$\"/api/datasets/views/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsViewsRetrieve", + methodName: "ApiDatasetsViewsRetrieveAsync", + pathTemplate: "$\"/api/datasets/views/{id}/\"", + 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); - ProcessApiDatasetsViewsRetrieveResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsViewsRetrieve", + methodName: "ApiDatasetsViewsRetrieveAsync", + pathTemplate: "$\"/api/datasets/views/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.DatasetView.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.DatasetView.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessApiDatasetsViewsRetrieveResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsViewsRetrieve", + methodName: "ApiDatasetsViewsRetrieveAsync", + pathTemplate: "$\"/api/datasets/views/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsViewsRetrieve", + methodName: "ApiDatasetsViewsRetrieveAsync", + pathTemplate: "$\"/api/datasets/views/{id}/\"", + 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); + ProcessApiDatasetsViewsRetrieveResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.DatasetView.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.DatasetView.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.DatasetsClient.ApiDatasetsViewsUpdate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.DatasetsClient.ApiDatasetsViewsUpdate.g.cs index 4567601..31da1f0 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.DatasetsClient.ApiDatasetsViewsUpdate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.DatasetsClient.ApiDatasetsViewsUpdate.g.cs @@ -14,6 +14,7 @@ public partial class DatasetsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -48,12 +49,14 @@ partial void ProcessApiDatasetsViewsUpdateResponseContent( /// /// /// + /// 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 ApiDatasetsViewsUpdateAsync( string id, global::LabelStudio.DatasetViewRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -71,22 +74,43 @@ partial void ProcessApiDatasetsViewsUpdateResponseContent( securityRequirements: s_ApiDatasetsViewsUpdateSecurityRequirements, operationName: "ApiDatasetsViewsUpdateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/datasets/views/{id}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/datasets/views/{id}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -96,119 +120,278 @@ partial void ProcessApiDatasetsViewsUpdateResponseContent( __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); - PrepareApiDatasetsViewsUpdateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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::LabelStudio.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); + PrepareApiDatasetsViewsUpdateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiDatasetsViewsUpdateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsViewsUpdate", + methodName: "ApiDatasetsViewsUpdateAsync", + pathTemplate: "$\"/api/datasets/views/{id}/\"", + 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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsViewsUpdate", + methodName: "ApiDatasetsViewsUpdateAsync", + pathTemplate: "$\"/api/datasets/views/{id}/\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessApiDatasetsViewsUpdateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsViewsUpdate", + methodName: "ApiDatasetsViewsUpdateAsync", + pathTemplate: "$\"/api/datasets/views/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.DatasetView.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.DatasetView.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessApiDatasetsViewsUpdateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsViewsUpdate", + methodName: "ApiDatasetsViewsUpdateAsync", + pathTemplate: "$\"/api/datasets/views/{id}/\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetsViewsUpdate", + methodName: "ApiDatasetsViewsUpdateAsync", + pathTemplate: "$\"/api/datasets/views/{id}/\"", + httpMethod: "PUT", + 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); + ProcessApiDatasetsViewsUpdateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.DatasetView.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.DatasetView.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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(); + } } /// /// Put dataset view
@@ -234,6 +417,7 @@ partial void ProcessApiDatasetsViewsUpdateResponseContent( /// /// User who made this view /// + /// 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 ApiDatasetsViewsUpdateAsync( @@ -245,6 +429,7 @@ partial void ProcessApiDatasetsViewsUpdateResponseContent( object? ordering = default, object? selectedItems = default, int? user = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.DatasetViewRequest @@ -261,6 +446,7 @@ partial void ProcessApiDatasetsViewsUpdateResponseContent( return await ApiDatasetsViewsUpdateAsync( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.DatasetsClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.DatasetsClient.g.cs index 6a8f6e3..bc32ab2 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.DatasetsClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.DatasetsClient.g.cs @@ -30,6 +30,9 @@ public sealed partial class DatasetsClient : global::LabelStudio.IDatasetsClient #if DEBUG = true; #endif + + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public DatasetsClient( 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 DatasetsClient. + /// 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 DatasetsClient( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::LabelStudio.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::LabelStudio.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/LabelStudio/Generated/LabelStudio.Dimensions2Client.CancelBackfill.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Dimensions2Client.CancelBackfill.g.cs index 314cda5..fd00002 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Dimensions2Client.CancelBackfill.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Dimensions2Client.CancelBackfill.g.cs @@ -14,6 +14,7 @@ public partial class Dimensions2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -54,11 +55,13 @@ partial void ProcessCancelBackfillResponseContent( ///
/// /// + /// 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 CancelBackfillAsync( int? jobId = default, int? projectId = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -74,26 +77,47 @@ partial void ProcessCancelBackfillResponseContent( securityRequirements: s_CancelBackfillSecurityRequirements, operationName: "CancelBackfillAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/dimensions/backfill/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("job_id", jobId?.ToString()) - .AddOptionalParameter("project_id", projectId?.ToString()) - ; - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/dimensions/backfill/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("job_id", jobId?.ToString()) + .AddOptionalParameter("project_id", projectId?.ToString()) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -103,189 +127,348 @@ partial void ProcessCancelBackfillResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCancelBackfillRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - jobId: jobId, - projectId: projectId); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCancelBackfillRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + jobId: jobId, + projectId: projectId); - 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); - ProcessCancelBackfillResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // - if ((int)__response.StatusCode == 403) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_403 = null; - global::System.Exception? __exception_403 = null; - string? __value_403 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CancelBackfill", + methodName: "CancelBackfillAsync", + pathTemplate: "\"/api/dimensions/backfill/\"", + 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_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, 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_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CancelBackfill", + methodName: "CancelBackfillAsync", + pathTemplate: "\"/api/dimensions/backfill/\"", + 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_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - } - catch (global::System.Exception __ex) - { - __exception_403 = __ex; - } - throw new global::LabelStudio.ApiException( - message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_403, - statusCode: __response.StatusCode) - { - ResponseBody = __content_403, - ResponseObject = __value_403, - 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; - string? __value_404 = null; - try - { - if (ReadResponseAsString) + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_404 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(string), JsonSerializerContext); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CancelBackfill", + methodName: "CancelBackfillAsync", + pathTemplate: "\"/api/dimensions/backfill/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else - { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_404 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(string), JsonSerializerContext); - } + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_404 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::LabelStudio.ApiException( - message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_404, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_404, - ResponseObject = __value_404, - 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); - ProcessCancelBackfillResponseContent( + response: __response); + ProcessCancelBackfillResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::LabelStudio.AgreementV2BackfillCancelResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CancelBackfill", + methodName: "CancelBackfillAsync", + pathTemplate: "\"/api/dimensions/backfill/\"", + 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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CancelBackfill", + methodName: "CancelBackfillAsync", + pathTemplate: "\"/api/dimensions/backfill/\"", + 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); + // + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + string? __value_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::LabelStudio.AgreementV2BackfillCancelResponse.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_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } + + throw new global::LabelStudio.ApiException( + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + statusCode: __response.StatusCode) + { + ResponseBody = __content_403, + ResponseObject = __value_403, + 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; + string? __value_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_404 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(string), JsonSerializerContext); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_404 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(string), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } + + throw new global::LabelStudio.ApiException( + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + statusCode: __response.StatusCode) + { + ResponseBody = __content_404, + ResponseObject = __value_404, + 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); + ProcessCancelBackfillResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.AgreementV2BackfillCancelResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.AgreementV2BackfillCancelResponse.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.Dimensions2Client.Create.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Dimensions2Client.Create.g.cs index 651544e..b5a6072 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Dimensions2Client.Create.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Dimensions2Client.Create.g.cs @@ -14,6 +14,7 @@ public partial class Dimensions2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -54,12 +55,14 @@ partial void ProcessCreateResponseContent( /// /// /// + /// 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 CreateAsync( int projectPk, global::LabelStudio.DimensionCreateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -77,22 +80,43 @@ partial void ProcessCreateResponseContent( securityRequirements: s_CreateSecurityRequirements, operationName: "CreateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{projectPk}/dimensions/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{projectPk}/dimensions/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -102,119 +126,278 @@ partial void ProcessCreateResponseContent( __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); - PrepareCreateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - projectPk: projectPk, - 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::LabelStudio.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); + PrepareCreateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + projectPk: projectPk, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "$\"/api/projects/{projectPk}/dimensions/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "$\"/api/projects/{projectPk}/dimensions/\"", + 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); - ProcessCreateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "$\"/api/projects/{projectPk}/dimensions/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.Dimension.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.Dimension.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessCreateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "$\"/api/projects/{projectPk}/dimensions/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "$\"/api/projects/{projectPk}/dimensions/\"", + 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); + ProcessCreateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.Dimension.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.Dimension.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 dimension
@@ -251,6 +434,7 @@ partial void ProcessCreateResponseContent( /// /// Display order within the project /// + /// 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 CreateAsync( @@ -263,6 +447,7 @@ partial void ProcessCreateResponseContent( object? metricParams = default, string? metricType = default, int? order = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.DimensionCreateRequest @@ -280,6 +465,7 @@ partial void ProcessCreateResponseContent( return await CreateAsync( projectPk: projectPk, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.Dimensions2Client.Delete.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Dimensions2Client.Delete.g.cs index 2054212..d193dde 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Dimensions2Client.Delete.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Dimensions2Client.Delete.g.cs @@ -14,6 +14,7 @@ public partial class Dimensions2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -49,11 +50,13 @@ partial void ProcessDeleteResponse( ///
/// /// + /// 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 DeleteAsync( int id, int projectPk, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -69,22 +72,43 @@ partial void ProcessDeleteResponse( securityRequirements: s_DeleteSecurityRequirements, operationName: "DeleteAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{projectPk}/dimensions/{id}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{projectPk}/dimensions/{id}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,97 +118,256 @@ partial void ProcessDeleteResponse( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDeleteRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - projectPk: projectPk); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDeleteRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + projectPk: projectPk); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/projects/{projectPk}/dimensions/{id}/\"", + 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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/projects/{projectPk}/dimensions/{id}/\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessDeleteResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/projects/{projectPk}/dimensions/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessDeleteResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/projects/{projectPk}/dimensions/{id}/\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/projects/{projectPk}/dimensions/{id}/\"", + httpMethod: "DELETE", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.Dimensions2Client.Get.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Dimensions2Client.Get.g.cs index 9116740..3eda833 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Dimensions2Client.Get.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Dimensions2Client.Get.g.cs @@ -14,6 +14,7 @@ public partial class Dimensions2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -54,11 +55,13 @@ partial void ProcessGetResponseContent( /// /// /// + /// 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 GetAsync( int id, int projectPk, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -74,22 +77,43 @@ partial void ProcessGetResponseContent( securityRequirements: s_GetSecurityRequirements, operationName: "GetAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{projectPk}/dimensions/{id}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{projectPk}/dimensions/{id}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -99,113 +123,272 @@ partial void ProcessGetResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - projectPk: projectPk); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + projectPk: projectPk); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/projects/{projectPk}/dimensions/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/projects/{projectPk}/dimensions/{id}/\"", + 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); - ProcessGetResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/projects/{projectPk}/dimensions/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.Dimension.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.Dimension.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGetResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/projects/{projectPk}/dimensions/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/projects/{projectPk}/dimensions/{id}/\"", + 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); + ProcessGetResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.Dimension.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.Dimension.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.Dimensions2Client.GetBackfillStatus.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Dimensions2Client.GetBackfillStatus.g.cs index 48b2a75..fb7151f 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Dimensions2Client.GetBackfillStatus.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Dimensions2Client.GetBackfillStatus.g.cs @@ -14,6 +14,7 @@ public partial class Dimensions2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -54,11 +55,13 @@ partial void ProcessGetBackfillStatusResponseContent( /// /// /// + /// 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 GetBackfillStatusAsync( int? jobId = default, int? projectId = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -74,26 +77,47 @@ partial void ProcessGetBackfillStatusResponseContent( securityRequirements: s_GetBackfillStatusSecurityRequirements, operationName: "GetBackfillStatusAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/dimensions/backfill/status/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("job_id", jobId?.ToString()) - .AddOptionalParameter("project_id", projectId?.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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/dimensions/backfill/status/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("job_id", jobId?.ToString()) + .AddOptionalParameter("project_id", projectId?.ToString()) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -103,189 +127,348 @@ partial void ProcessGetBackfillStatusResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetBackfillStatusRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - jobId: jobId, - projectId: projectId); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetBackfillStatusRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + jobId: jobId, + projectId: projectId); - 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); - ProcessGetBackfillStatusResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // - if ((int)__response.StatusCode == 403) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_403 = null; - global::System.Exception? __exception_403 = null; - string? __value_403 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetBackfillStatus", + methodName: "GetBackfillStatusAsync", + pathTemplate: "\"/api/dimensions/backfill/status/\"", + 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_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, 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_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetBackfillStatus", + methodName: "GetBackfillStatusAsync", + pathTemplate: "\"/api/dimensions/backfill/status/\"", + 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_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - } - catch (global::System.Exception __ex) - { - __exception_403 = __ex; - } - throw new global::LabelStudio.ApiException( - message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_403, - statusCode: __response.StatusCode) - { - ResponseBody = __content_403, - ResponseObject = __value_403, - 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; - string? __value_404 = null; - try - { - if (ReadResponseAsString) + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_404 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(string), JsonSerializerContext); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetBackfillStatus", + methodName: "GetBackfillStatusAsync", + pathTemplate: "\"/api/dimensions/backfill/status/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else - { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_404 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(string), JsonSerializerContext); - } + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_404 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::LabelStudio.ApiException( - message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_404, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_404, - ResponseObject = __value_404, - 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); - ProcessGetBackfillStatusResponseContent( + response: __response); + ProcessGetBackfillStatusResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::LabelStudio.AgreementV2BackfillJob.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetBackfillStatus", + methodName: "GetBackfillStatusAsync", + pathTemplate: "\"/api/dimensions/backfill/status/\"", + 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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetBackfillStatus", + methodName: "GetBackfillStatusAsync", + pathTemplate: "\"/api/dimensions/backfill/status/\"", + 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); + // + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + string? __value_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::LabelStudio.AgreementV2BackfillJob.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_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } + + throw new global::LabelStudio.ApiException( + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + statusCode: __response.StatusCode) + { + ResponseBody = __content_403, + ResponseObject = __value_403, + 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; + string? __value_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_404 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(string), JsonSerializerContext); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_404 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(string), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } + + throw new global::LabelStudio.ApiException( + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + statusCode: __response.StatusCode) + { + ResponseBody = __content_404, + ResponseObject = __value_404, + 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); + ProcessGetBackfillStatusResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.AgreementV2BackfillJob.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.AgreementV2BackfillJob.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.Dimensions2Client.List.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Dimensions2Client.List.g.cs index 6d22817..c097c96 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Dimensions2Client.List.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Dimensions2Client.List.g.cs @@ -14,6 +14,7 @@ public partial class Dimensions2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -60,6 +61,7 @@ partial void ProcessListResponseContent( /// /// /// + /// 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> ListAsync( @@ -67,6 +69,7 @@ partial void ProcessListResponseContent( string? agreementMethodology = default, bool? isActive = default, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -84,27 +87,48 @@ partial void ProcessListResponseContent( securityRequirements: s_ListSecurityRequirements, operationName: "ListAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{projectPk}/dimensions/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("agreement_methodology", agreementMethodology) - .AddOptionalParameter("is_active", isActive?.ToString().ToLowerInvariant()) - .AddOptionalParameter("ordering", ordering) - ; - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{projectPk}/dimensions/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("agreement_methodology", agreementMethodology) + .AddOptionalParameter("is_active", isActive?.ToString().ToLowerInvariant()) + .AddOptionalParameter("ordering", ordering) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,115 +138,274 @@ partial void ProcessListResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareListRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - agreementMethodology: agreementMethodology, - isActive: isActive, - ordering: ordering, - projectPk: projectPk); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareListRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + agreementMethodology: agreementMethodology, + isActive: isActive, + ordering: ordering, + projectPk: projectPk); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessListResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "$\"/api/projects/{projectPk}/dimensions/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "$\"/api/projects/{projectPk}/dimensions/\"", + 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); - ProcessListResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "$\"/api/projects/{projectPk}/dimensions/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessListResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "$\"/api/projects/{projectPk}/dimensions/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "$\"/api/projects/{projectPk}/dimensions/\"", + 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); + ProcessListResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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 + (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.Dimensions2Client.ListBackfills.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Dimensions2Client.ListBackfills.g.cs index 5312317..b1d5bcd 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Dimensions2Client.ListBackfills.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Dimensions2Client.ListBackfills.g.cs @@ -14,6 +14,7 @@ public partial class Dimensions2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,10 +52,12 @@ partial void ProcessListBackfillsResponseContent( /// Retrieve Agreement V2 backfill jobs for the authenticated user's active organization, ordered by most-recently created first. Supports page / page_size query params (default 50 per page, max 500). Requires administrator or owner role and the Agreement V2 feature flag. /// /// + /// 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> ListBackfillsAsync( string? status = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -69,25 +72,46 @@ partial void ProcessListBackfillsResponseContent( securityRequirements: s_ListBackfillsSecurityRequirements, operationName: "ListBackfillsAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/dimensions/backfill/jobs/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("status", status) - ; - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/dimensions/backfill/jobs/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("status", status) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -97,188 +121,347 @@ partial void ProcessListBackfillsResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareListBackfillsRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - status: status); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareListBackfillsRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + status: status); - 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); - ProcessListBackfillsResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // - if ((int)__response.StatusCode == 400) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_400 = null; - global::System.Exception? __exception_400 = null; - string? __value_400 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListBackfills", + methodName: "ListBackfillsAsync", + pathTemplate: "\"/api/dimensions/backfill/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_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, 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_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListBackfills", + methodName: "ListBackfillsAsync", + pathTemplate: "\"/api/dimensions/backfill/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; + } - __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - } - catch (global::System.Exception __ex) - { - __exception_400 = __ex; - } - throw new global::LabelStudio.ApiException( - message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_400, - statusCode: __response.StatusCode) - { - ResponseBody = __content_400, - ResponseObject = __value_400, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // - if ((int)__response.StatusCode == 403) - { - string? __content_403 = null; - global::System.Exception? __exception_403 = null; - string? __value_403 = null; - try - { - if (ReadResponseAsString) + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListBackfills", + methodName: "ListBackfillsAsync", + pathTemplate: "\"/api/dimensions/backfill/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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else - { - __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext); - } + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_403 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::LabelStudio.ApiException( - message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_403, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_403, - ResponseObject = __value_403, - 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); - ProcessListBackfillsResponseContent( + response: __response); + ProcessListBackfillsResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListBackfills", + methodName: "ListBackfillsAsync", + pathTemplate: "\"/api/dimensions/backfill/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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListBackfills", + methodName: "ListBackfillsAsync", + pathTemplate: "\"/api/dimensions/backfill/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); + // + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + string? __value_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::LabelStudio.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseObject = __value_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + string? __value_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } + + throw new global::LabelStudio.ApiException( + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + statusCode: __response.StatusCode) + { + ResponseBody = __content_403, + ResponseObject = __value_403, + 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); + ProcessListBackfillsResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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 + (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.Dimensions2Client.TriggerBackfill.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Dimensions2Client.TriggerBackfill.g.cs index 3a52d2c..0610ab0 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Dimensions2Client.TriggerBackfill.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Dimensions2Client.TriggerBackfill.g.cs @@ -14,6 +14,7 @@ public partial class Dimensions2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -55,11 +56,13 @@ partial void ProcessTriggerBackfillResponseContent( /// Requires administrator or owner role and the Agreement V2 feature flag. /// /// + /// 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 TriggerBackfillAsync( global::LabelStudio.AgreementV2BackfillTriggerRequestRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -76,22 +79,43 @@ partial void ProcessTriggerBackfillResponseContent( securityRequirements: s_TriggerBackfillSecurityRequirements, operationName: "TriggerBackfillAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/dimensions/backfill/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/dimensions/backfill/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -101,232 +125,391 @@ partial void ProcessTriggerBackfillResponseContent( __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); - PrepareTriggerBackfillRequest( - 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::LabelStudio.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); + PrepareTriggerBackfillRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessTriggerBackfillResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // - if ((int)__response.StatusCode == 400) + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_400 = null; - global::System.Exception? __exception_400 = null; - string? __value_400 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "TriggerBackfill", + methodName: "TriggerBackfillAsync", + pathTemplate: "\"/api/dimensions/backfill/\"", + 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_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, 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_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "TriggerBackfill", + methodName: "TriggerBackfillAsync", + pathTemplate: "\"/api/dimensions/backfill/\"", + 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_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - } - catch (global::System.Exception __ex) - { - __exception_400 = __ex; - } - throw new global::LabelStudio.ApiException( - message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_400, - statusCode: __response.StatusCode) - { - ResponseBody = __content_400, - ResponseObject = __value_400, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // - if ((int)__response.StatusCode == 403) - { - string? __content_403 = null; - global::System.Exception? __exception_403 = null; - string? __value_403 = null; - try - { - if (ReadResponseAsString) + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "TriggerBackfill", + methodName: "TriggerBackfillAsync", + pathTemplate: "\"/api/dimensions/backfill/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else - { - __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext); - } + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_403 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::LabelStudio.ApiException( - message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_403, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_403, - ResponseObject = __value_403, - 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; - string? __value_404 = null; - try - { - if (ReadResponseAsString) - { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_404 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(string), JsonSerializerContext); - } - else - { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_404 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(string), JsonSerializerContext); - } + ProcessResponse( + client: HttpClient, + response: __response); + ProcessTriggerBackfillResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "TriggerBackfill", + methodName: "TriggerBackfillAsync", + pathTemplate: "\"/api/dimensions/backfill/\"", + 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 { - __exception_404 = __ex; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "TriggerBackfill", + methodName: "TriggerBackfillAsync", + pathTemplate: "\"/api/dimensions/backfill/\"", + 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 ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + string? __value_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - throw new global::LabelStudio.ApiException( - message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_404, - statusCode: __response.StatusCode) - { - ResponseBody = __content_404, - ResponseObject = __value_404, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } + __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + throw new global::LabelStudio.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseObject = __value_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + string? __value_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessTriggerBackfillResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } - try - { - __response.EnsureSuccessStatusCode(); + throw new global::LabelStudio.ApiException( + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + statusCode: __response.StatusCode) + { + ResponseBody = __content_403, + ResponseObject = __value_403, + 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; + string? __value_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_404 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(string), JsonSerializerContext); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - global::LabelStudio.AgreementV2BackfillTriggerResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); - } - catch (global::System.Exception __ex) - { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - cancellationToken -#endif - ).ConfigureAwait(false); + __value_404 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(string), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } - return - await global::LabelStudio.AgreementV2BackfillTriggerResponse.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) - { - } + throw new global::LabelStudio.ApiException( + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + statusCode: __response.StatusCode) + { + ResponseBody = __content_404, + ResponseObject = __value_404, + 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); + ProcessTriggerBackfillResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.AgreementV2BackfillTriggerResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.AgreementV2BackfillTriggerResponse.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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(); + } } /// /// ✨ Trigger Agreement V2 backfill
@@ -351,12 +534,14 @@ partial void ProcessTriggerBackfillResponseContent( /// /// Backfill a single specific project. /// + /// 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 TriggerBackfillAsync( bool? allProjects = default, int? numProjects = default, int? projectId = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.AgreementV2BackfillTriggerRequestRequest @@ -368,6 +553,7 @@ partial void ProcessTriggerBackfillResponseContent( return await TriggerBackfillAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.Dimensions2Client.Update.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Dimensions2Client.Update.g.cs index 3dbdf5f..87c6b82 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Dimensions2Client.Update.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Dimensions2Client.Update.g.cs @@ -14,6 +14,7 @@ public partial class Dimensions2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -57,6 +58,7 @@ partial void ProcessUpdateResponseContent( /// /// /// + /// 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 UpdateAsync( @@ -64,6 +66,7 @@ partial void ProcessUpdateResponseContent( int projectPk, global::LabelStudio.PatchedDimensionRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -82,22 +85,43 @@ partial void ProcessUpdateResponseContent( securityRequirements: s_UpdateSecurityRequirements, operationName: "UpdateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{projectPk}/dimensions/{id}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{projectPk}/dimensions/{id}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -107,120 +131,279 @@ partial void ProcessUpdateResponseContent( __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); - PrepareUpdateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - projectPk: projectPk, - 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::LabelStudio.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); + PrepareUpdateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + projectPk: projectPk, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessUpdateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/projects/{projectPk}/dimensions/{id}/\"", + 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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/projects/{projectPk}/dimensions/{id}/\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessUpdateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/projects/{projectPk}/dimensions/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.Dimension.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.Dimension.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessUpdateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/projects/{projectPk}/dimensions/{id}/\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/projects/{projectPk}/dimensions/{id}/\"", + httpMethod: "PATCH", + 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); + ProcessUpdateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.Dimension.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.Dimension.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 dimension
@@ -261,6 +444,7 @@ partial void ProcessUpdateResponseContent( /// /// Display order within the project /// + /// 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 UpdateAsync( @@ -275,6 +459,7 @@ partial void ProcessUpdateResponseContent( string? metricType = default, string? name = default, int? order = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.PatchedDimensionRequest @@ -294,6 +479,7 @@ partial void ProcessUpdateResponseContent( id: id, projectPk: projectPk, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.Dimensions2Client.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Dimensions2Client.g.cs index 7cc7f5a..7385ceb 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Dimensions2Client.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Dimensions2Client.g.cs @@ -30,6 +30,9 @@ public sealed partial class Dimensions2Client : global::LabelStudio.IDimensions2 #if DEBUG = true; #endif + + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public Dimensions2Client( 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 Dimensions2Client. + /// 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 Dimensions2Client( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::LabelStudio.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::LabelStudio.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/LabelStudio/Generated/LabelStudio.DimensionsClient.ApiProjectsDimensionsUpdate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.DimensionsClient.ApiProjectsDimensionsUpdate.g.cs index d313cae..b9e0fe2 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.DimensionsClient.ApiProjectsDimensionsUpdate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.DimensionsClient.ApiProjectsDimensionsUpdate.g.cs @@ -14,6 +14,7 @@ public partial class DimensionsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -57,6 +58,7 @@ partial void ProcessApiProjectsDimensionsUpdateResponseContent( /// /// /// + /// 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 ApiProjectsDimensionsUpdateAsync( @@ -64,6 +66,7 @@ partial void ProcessApiProjectsDimensionsUpdateResponseContent( int projectPk, global::LabelStudio.DimensionRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -82,22 +85,43 @@ partial void ProcessApiProjectsDimensionsUpdateResponseContent( securityRequirements: s_ApiProjectsDimensionsUpdateSecurityRequirements, operationName: "ApiProjectsDimensionsUpdateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{projectPk}/dimensions/{id}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{projectPk}/dimensions/{id}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -107,120 +131,279 @@ partial void ProcessApiProjectsDimensionsUpdateResponseContent( __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); - PrepareApiProjectsDimensionsUpdateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - projectPk: projectPk, - 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::LabelStudio.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); + PrepareApiProjectsDimensionsUpdateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + projectPk: projectPk, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiProjectsDimensionsUpdateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiProjectsDimensionsUpdate", + methodName: "ApiProjectsDimensionsUpdateAsync", + pathTemplate: "$\"/api/projects/{projectPk}/dimensions/{id}/\"", + 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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiProjectsDimensionsUpdate", + methodName: "ApiProjectsDimensionsUpdateAsync", + pathTemplate: "$\"/api/projects/{projectPk}/dimensions/{id}/\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessApiProjectsDimensionsUpdateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiProjectsDimensionsUpdate", + methodName: "ApiProjectsDimensionsUpdateAsync", + pathTemplate: "$\"/api/projects/{projectPk}/dimensions/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.Dimension.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.Dimension.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessApiProjectsDimensionsUpdateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiProjectsDimensionsUpdate", + methodName: "ApiProjectsDimensionsUpdateAsync", + pathTemplate: "$\"/api/projects/{projectPk}/dimensions/{id}/\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiProjectsDimensionsUpdate", + methodName: "ApiProjectsDimensionsUpdateAsync", + pathTemplate: "$\"/api/projects/{projectPk}/dimensions/{id}/\"", + httpMethod: "PUT", + 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); + ProcessApiProjectsDimensionsUpdateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.Dimension.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.Dimension.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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(); + } } /// /// ✨ Put dimension
@@ -261,6 +444,7 @@ partial void ProcessApiProjectsDimensionsUpdateResponseContent( /// /// Display order within the project /// + /// 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 ApiProjectsDimensionsUpdateAsync( @@ -275,6 +459,7 @@ partial void ProcessApiProjectsDimensionsUpdateResponseContent( object? metricParams = default, string? metricType = default, int? order = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.DimensionRequest @@ -294,6 +479,7 @@ partial void ProcessApiProjectsDimensionsUpdateResponseContent( id: id, projectPk: projectPk, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.DimensionsClient.Get2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.DimensionsClient.Get2.g.cs index 3568b51..1bb5204 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.DimensionsClient.Get2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.DimensionsClient.Get2.g.cs @@ -14,6 +14,7 @@ public partial class DimensionsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -60,6 +61,7 @@ partial void ProcessGet2ResponseContent( /// /// /// + /// 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 Get2Async( @@ -67,6 +69,7 @@ partial void ProcessGet2ResponseContent( global::LabelStudio.AgreementSelectionRequest selection, int taskPk, int? dimension = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -84,25 +87,46 @@ partial void ProcessGet2ResponseContent( securityRequirements: s_Get2SecurityRequirements, operationName: "Get2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{projectPk}/tasks/{taskPk}/agreement-matrix", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("dimension", dimension?.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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{projectPk}/tasks/{taskPk}/agreement-matrix", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("dimension", dimension?.ToString()) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -112,115 +136,274 @@ partial void ProcessGet2ResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGet2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - dimension: dimension, - projectPk: projectPk, - selection: selection, - taskPk: taskPk); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGet2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + dimension: dimension, + projectPk: projectPk, + selection: selection, + taskPk: taskPk); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGet2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "$\"/api/projects/{projectPk}/tasks/{taskPk}/agreement-matrix\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "$\"/api/projects/{projectPk}/tasks/{taskPk}/agreement-matrix\"", + 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); - ProcessGet2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "$\"/api/projects/{projectPk}/tasks/{taskPk}/agreement-matrix\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.TaskAgreementMatrixResponse.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.TaskAgreementMatrixResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGet2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "$\"/api/projects/{projectPk}/tasks/{taskPk}/agreement-matrix\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "$\"/api/projects/{projectPk}/tasks/{taskPk}/agreement-matrix\"", + 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); + ProcessGet2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.TaskAgreementMatrixResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.TaskAgreementMatrixResponse.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.DimensionsClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.DimensionsClient.g.cs index 5d74a22..84e629c 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.DimensionsClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.DimensionsClient.g.cs @@ -30,6 +30,9 @@ public sealed partial class DimensionsClient : global::LabelStudio.IDimensionsCl #if DEBUG = true; #endif + + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public DimensionsClient( 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 DimensionsClient. + /// 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 DimensionsClient( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::LabelStudio.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::LabelStudio.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ExportClient.Convert.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ExportClient.Convert.g.cs index 649f403..dd90824 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ExportClient.Convert.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ExportClient.Convert.g.cs @@ -14,6 +14,7 @@ public partial class ExportClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,6 +52,7 @@ partial void ProcessConvertResponseContent( /// /// /// + /// 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 ConvertAsync( @@ -58,6 +60,7 @@ partial void ProcessConvertResponseContent( int id, global::LabelStudio.ExportConvertRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -76,22 +79,43 @@ partial void ProcessConvertResponseContent( securityRequirements: s_ConvertSecurityRequirements, operationName: "ConvertAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{id}/exports/{exportPk}/convert", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{id}/exports/{exportPk}/convert", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -101,120 +125,279 @@ partial void ProcessConvertResponseContent( __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); - PrepareConvertRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - exportPk: exportPk, - id: id, - 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::LabelStudio.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); + PrepareConvertRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + exportPk: exportPk, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessConvertResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Convert", + methodName: "ConvertAsync", + pathTemplate: "$\"/api/projects/{id}/exports/{exportPk}/convert\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Convert", + methodName: "ConvertAsync", + pathTemplate: "$\"/api/projects/{id}/exports/{exportPk}/convert\"", + 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); - ProcessConvertResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Convert", + methodName: "ConvertAsync", + pathTemplate: "$\"/api/projects/{id}/exports/{exportPk}/convert\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.ApiProjectsExportsConvertCreateResponse.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.ApiProjectsExportsConvertCreateResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessConvertResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Convert", + methodName: "ConvertAsync", + pathTemplate: "$\"/api/projects/{id}/exports/{exportPk}/convert\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Convert", + methodName: "ConvertAsync", + pathTemplate: "$\"/api/projects/{id}/exports/{exportPk}/convert\"", + 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); + ProcessConvertResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.ApiProjectsExportsConvertCreateResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiProjectsExportsConvertCreateResponse.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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(); + } } /// /// Export conversion
@@ -228,6 +411,7 @@ partial void ProcessConvertResponseContent( /// /// Export file format. /// + /// 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 ConvertAsync( @@ -235,6 +419,7 @@ partial void ProcessConvertResponseContent( int id, string exportType, bool? downloadResources = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.ExportConvertRequest @@ -247,6 +432,7 @@ partial void ProcessConvertResponseContent( exportPk: exportPk, id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ExportClient.Create.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ExportClient.Create.g.cs index 4cd8124..54bfbb6 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ExportClient.Create.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ExportClient.Create.g.cs @@ -14,6 +14,7 @@ public partial class ExportClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -48,12 +49,14 @@ partial void ProcessCreateResponseContent( ///
/// /// + /// 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 CreateAsync( int id, global::LabelStudio.LseExportCreateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -71,22 +74,43 @@ partial void ProcessCreateResponseContent( securityRequirements: s_CreateSecurityRequirements, operationName: "CreateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{id}/exports/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{id}/exports/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,119 +120,278 @@ partial void ProcessCreateResponseContent( __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); - PrepareCreateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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::LabelStudio.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); + PrepareCreateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "$\"/api/projects/{id}/exports/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "$\"/api/projects/{id}/exports/\"", + 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); - ProcessCreateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "$\"/api/projects/{id}/exports/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.LseExportCreate.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.LseExportCreate.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessCreateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "$\"/api/projects/{id}/exports/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "$\"/api/projects/{id}/exports/\"", + 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); + ProcessCreateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.LseExportCreate.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.LseExportCreate.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 new export snapshot
@@ -232,6 +415,7 @@ partial void ProcessCreateResponseContent( /// /// /// + /// 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 CreateAsync( @@ -246,6 +430,7 @@ partial void ProcessCreateResponseContent( global::LabelStudio.Status7bfEnum? status = default, global::LabelStudio.LseTaskFilterOptionsRequest? taskFilterOptions = default, string? title = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.LseExportCreateRequest @@ -265,6 +450,7 @@ partial void ProcessCreateResponseContent( return await CreateAsync( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ExportClient.Delete.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ExportClient.Delete.g.cs index 9c1c500..7100dd7 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ExportClient.Delete.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ExportClient.Delete.g.cs @@ -14,6 +14,7 @@ public partial class ExportClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -43,11 +44,13 @@ partial void ProcessDeleteResponse( ///
/// /// + /// 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 DeleteAsync( int exportPk, int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -63,22 +66,43 @@ partial void ProcessDeleteResponse( securityRequirements: s_DeleteSecurityRequirements, operationName: "DeleteAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{id}/exports/{exportPk}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{id}/exports/{exportPk}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -88,97 +112,256 @@ partial void ProcessDeleteResponse( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDeleteRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - exportPk: exportPk, - id: id); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDeleteRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + exportPk: exportPk, + id: id); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/projects/{id}/exports/{exportPk}\"", + 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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/projects/{id}/exports/{exportPk}\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessDeleteResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/projects/{id}/exports/{exportPk}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessDeleteResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/projects/{id}/exports/{exportPk}\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/projects/{id}/exports/{exportPk}\"", + httpMethod: "DELETE", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.ExportClient.Download.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ExportClient.Download.g.cs index 13fc863..fe27d02 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ExportClient.Download.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ExportClient.Download.g.cs @@ -14,6 +14,7 @@ public partial class ExportClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -56,12 +57,14 @@ partial void ProcessDownloadResponseContent( /// /// /// + /// 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 DownloadAsync( int exportPk, int id, string? exportType = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -78,25 +81,46 @@ partial void ProcessDownloadResponseContent( securityRequirements: s_DownloadSecurityRequirements, operationName: "DownloadAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{id}/exports/{exportPk}/download", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("exportType", exportType) - ; - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{id}/exports/{exportPk}/download", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("exportType", exportType) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -106,105 +130,264 @@ partial void ProcessDownloadResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDownloadRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - exportType: exportType, - exportPk: exportPk, - id: id); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDownloadRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + exportType: exportType, + exportPk: exportPk, + id: id); + + return __httpRequest; + } - using var __response = await HttpClient.SendAsync( + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Download", + methodName: "DownloadAsync", + pathTemplate: "$\"/api/projects/{id}/exports/{exportPk}/download\"", + 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: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Download", + methodName: "DownloadAsync", + pathTemplate: "$\"/api/projects/{id}/exports/{exportPk}/download\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessDownloadResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsByteArrayAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Download", + methodName: "DownloadAsync", + pathTemplate: "$\"/api/projects/{id}/exports/{exportPk}/download\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessDownloadResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - - return __content; + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) - { - throw new global::LabelStudio.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 + + using (__response) { - __response.EnsureSuccessStatusCode(); - var __content = await __response.Content.ReadAsByteArrayAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - return __content; + ProcessResponse( + client: HttpClient, + response: __response); + ProcessDownloadResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Download", + methodName: "DownloadAsync", + pathTemplate: "$\"/api/projects/{id}/exports/{exportPk}/download\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Download", + methodName: "DownloadAsync", + pathTemplate: "$\"/api/projects/{id}/exports/{exportPk}/download\"", + 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.ReadAsByteArrayAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessDownloadResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return __content; + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.ExportClient.Get.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ExportClient.Get.g.cs index 733030e..e059aca 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ExportClient.Get.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ExportClient.Get.g.cs @@ -14,6 +14,7 @@ public partial class ExportClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -48,11 +49,13 @@ partial void ProcessGetResponseContent( ///
/// /// + /// 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 GetAsync( int exportPk, int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -68,22 +71,43 @@ partial void ProcessGetResponseContent( securityRequirements: s_GetSecurityRequirements, operationName: "GetAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{id}/exports/{exportPk}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{id}/exports/{exportPk}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -93,113 +117,272 @@ partial void ProcessGetResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - exportPk: exportPk, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + exportPk: exportPk, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/projects/{id}/exports/{exportPk}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/projects/{id}/exports/{exportPk}\"", + 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); - ProcessGetResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/projects/{id}/exports/{exportPk}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.Export.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.Export.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGetResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/projects/{id}/exports/{exportPk}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/projects/{id}/exports/{exportPk}\"", + 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); + ProcessGetResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.Export.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.Export.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.ExportClient.List.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ExportClient.List.g.cs index dcd5435..2a82ee6 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ExportClient.List.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ExportClient.List.g.cs @@ -14,6 +14,7 @@ public partial class ExportClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -48,11 +49,13 @@ partial void ProcessListResponseContent( ///
/// /// + /// 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> ListAsync( int id, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -68,25 +71,46 @@ partial void ProcessListResponseContent( securityRequirements: s_ListSecurityRequirements, operationName: "ListAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{id}/exports/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("ordering", ordering) - ; - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{id}/exports/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("ordering", ordering) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -96,113 +120,272 @@ partial void ProcessListResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareListRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - ordering: ordering); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareListRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + ordering: ordering); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessListResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "$\"/api/projects/{id}/exports/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "$\"/api/projects/{id}/exports/\"", + 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); - ProcessListResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "$\"/api/projects/{id}/exports/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessListResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "$\"/api/projects/{id}/exports/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "$\"/api/projects/{id}/exports/\"", + 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); + ProcessListResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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 + (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.ExportClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ExportClient.g.cs index fc60710..2dc25c1 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ExportClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ExportClient.g.cs @@ -30,6 +30,9 @@ public sealed partial class ExportClient : global::LabelStudio.IExportClient, gl #if DEBUG = true; #endif + + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public ExportClient( 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 ExportClient. + /// 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 ExportClient( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::LabelStudio.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::LabelStudio.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IActionsClient.Create.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IActionsClient.Create.g.cs index 1b45984..37148d5 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IActionsClient.Create.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IActionsClient.Create.g.cs @@ -12,6 +12,7 @@ public partial interface IActionsClient /// /// /// + /// 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 CreateAsync( @@ -20,6 +21,7 @@ public partial interface IActionsClient global::LabelStudio.ApiDmActionsCreateRequest request, int? view = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Post actions
@@ -37,6 +39,7 @@ public partial interface IActionsClient /// /// Task selection by IDs. If filters are applied, the selection will be applied to the filtered tasks.If "all" is `false`, `"included"` must be used. If "all" is `true`, `"excluded"` must be used.Examples: `{"all": false, "included": [1, 2, 3]}` or `{"all": true, "excluded": [4, 5]}` /// + /// 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 CreateAsync( @@ -46,6 +49,7 @@ public partial interface IActionsClient global::LabelStudio.ApiDmActionsCreateRequestFilters? filters = default, global::System.Collections.Generic.IList? ordering = default, global::LabelStudio.OneOf? selectedItems = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IActionsClient.List.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IActionsClient.List.g.cs index a780bc2..6f5b7d1 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IActionsClient.List.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IActionsClient.List.g.cs @@ -9,10 +9,12 @@ public partial interface IActionsClient /// Retrieve all the registered actions with descriptions that data manager can use. ///
/// + /// 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> ListAsync( int project, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IActionsClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IActionsClient.g.cs index f7d515e..b2d21e5 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IActionsClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IActionsClient.g.cs @@ -33,6 +33,11 @@ public partial interface IActionsClient : global::System.IDisposable ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IActivityLogsClient.List.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IActivityLogsClient.List.g.cs index a88134d..447f7ba 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IActivityLogsClient.List.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IActivityLogsClient.List.g.cs @@ -26,6 +26,7 @@ public partial interface IActivityLogsClient /// /// /// + /// 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> ListAsync( @@ -39,6 +40,7 @@ public partial interface IActivityLogsClient string? startDate = default, int? user = default, int? workspace = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IActivityLogsClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IActivityLogsClient.g.cs index b454a48..c9c9793 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IActivityLogsClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IActivityLogsClient.g.cs @@ -33,6 +33,11 @@ public partial interface IActivityLogsClient : global::System.IDisposable /// public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IAnalyticsClient.ApiAnalyticsKpisRetrieve.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IAnalyticsClient.ApiAnalyticsKpisRetrieve.g.cs index a5b9103..e230f0a 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IAnalyticsClient.ApiAnalyticsKpisRetrieve.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IAnalyticsClient.ApiAnalyticsKpisRetrieve.g.cs @@ -8,9 +8,11 @@ public partial interface IAnalyticsClient /// List all available KPIs
/// Returns metadata for all available KPI (Key Performance Indicator) classes. Each KPI includes its key, label, base class, dependencies, and configuration. This endpoint is useful for discovering available metrics and understanding their relationships and requirements. /// + /// 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> ApiAnalyticsKpisRetrieveAsync( + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IAnalyticsClient.ApiAnalyticsKpisRetrieve2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IAnalyticsClient.ApiAnalyticsKpisRetrieve2.g.cs index 2c30a40..06db17f 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IAnalyticsClient.ApiAnalyticsKpisRetrieve2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IAnalyticsClient.ApiAnalyticsKpisRetrieve2.g.cs @@ -17,6 +17,7 @@ public partial interface IAnalyticsClient /// /// /// + /// 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 ApiAnalyticsKpisRetrieve2Async( @@ -29,6 +30,7 @@ public partial interface IAnalyticsClient string? segmentByTime = default, bool? segmentByUser = default, global::System.DateTime? start = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IAnalyticsClient.ApiAnalyticsViewsCreate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IAnalyticsClient.ApiAnalyticsViewsCreate.g.cs index 1b6c4d6..65b7518 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IAnalyticsClient.ApiAnalyticsViewsCreate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IAnalyticsClient.ApiAnalyticsViewsCreate.g.cs @@ -19,11 +19,13 @@ public partial interface IAnalyticsClient /// * update / destroy — owner-only /// /// + /// 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 ApiAnalyticsViewsCreateAsync( global::LabelStudio.AnalyticsViewRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// CRUD endpoints for per-user analytics saved views.
@@ -45,12 +47,14 @@ public partial interface IAnalyticsClient /// /// /// + /// 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 ApiAnalyticsViewsCreateAsync( string name, global::LabelStudio.DashboardTypeEnum? dashboardType = default, object? filters = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IAnalyticsClient.ApiAnalyticsViewsDestroy.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IAnalyticsClient.ApiAnalyticsViewsDestroy.g.cs index eec09f8..b1f1507 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IAnalyticsClient.ApiAnalyticsViewsDestroy.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IAnalyticsClient.ApiAnalyticsViewsDestroy.g.cs @@ -19,10 +19,12 @@ public partial interface IAnalyticsClient /// * update / destroy — owner-only ///
/// + /// 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 ApiAnalyticsViewsDestroyAsync( global::System.Guid uuid, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IAnalyticsClient.ApiAnalyticsViewsList.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IAnalyticsClient.ApiAnalyticsViewsList.g.cs index 34886d0..18805af 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IAnalyticsClient.ApiAnalyticsViewsList.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IAnalyticsClient.ApiAnalyticsViewsList.g.cs @@ -19,10 +19,12 @@ public partial interface IAnalyticsClient /// * update / destroy — owner-only /// /// + /// 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> ApiAnalyticsViewsListAsync( string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IAnalyticsClient.ApiAnalyticsViewsPartialUpdate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IAnalyticsClient.ApiAnalyticsViewsPartialUpdate.g.cs index 2086893..d4cbf64 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IAnalyticsClient.ApiAnalyticsViewsPartialUpdate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IAnalyticsClient.ApiAnalyticsViewsPartialUpdate.g.cs @@ -20,12 +20,14 @@ public partial interface IAnalyticsClient /// /// /// + /// 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 ApiAnalyticsViewsPartialUpdateAsync( global::System.Guid uuid, global::LabelStudio.PatchedAnalyticsViewRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// CRUD endpoints for per-user analytics saved views.
@@ -48,6 +50,7 @@ public partial interface IAnalyticsClient /// /// /// + /// 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 ApiAnalyticsViewsPartialUpdateAsync( @@ -55,6 +58,7 @@ public partial interface IAnalyticsClient global::LabelStudio.DashboardTypeEnum? dashboardType = default, object? filters = default, string? name = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IAnalyticsClient.ApiAnalyticsViewsRetrieve.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IAnalyticsClient.ApiAnalyticsViewsRetrieve.g.cs index beccb25..2548eeb 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IAnalyticsClient.ApiAnalyticsViewsRetrieve.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IAnalyticsClient.ApiAnalyticsViewsRetrieve.g.cs @@ -19,10 +19,12 @@ public partial interface IAnalyticsClient /// * update / destroy — owner-only ///
/// + /// 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 ApiAnalyticsViewsRetrieveAsync( global::System.Guid uuid, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IAnalyticsClient.ApiAnalyticsViewsUpdate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IAnalyticsClient.ApiAnalyticsViewsUpdate.g.cs index 5f62af3..a6b8617 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IAnalyticsClient.ApiAnalyticsViewsUpdate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IAnalyticsClient.ApiAnalyticsViewsUpdate.g.cs @@ -20,12 +20,14 @@ public partial interface IAnalyticsClient /// /// /// + /// 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 ApiAnalyticsViewsUpdateAsync( global::System.Guid uuid, global::LabelStudio.AnalyticsViewRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// CRUD endpoints for per-user analytics saved views.
@@ -48,6 +50,7 @@ public partial interface IAnalyticsClient /// /// /// + /// 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 ApiAnalyticsViewsUpdateAsync( @@ -55,6 +58,7 @@ public partial interface IAnalyticsClient string name, global::LabelStudio.DashboardTypeEnum? dashboardType = default, object? filters = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IAnalyticsClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IAnalyticsClient.g.cs index ad643c6..74c3e8b 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IAnalyticsClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IAnalyticsClient.g.cs @@ -33,6 +33,11 @@ public partial interface IAnalyticsClient : global::System.IDisposable ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationHistoryClient.Delete.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationHistoryClient.Delete.g.cs index 8d349ac..cb7710f 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationHistoryClient.Delete.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationHistoryClient.Delete.g.cs @@ -17,12 +17,14 @@ public partial interface IAnnotationHistoryClient /// /// /// + /// 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 DeleteAsync( int? annotation = default, int? project = default, int? task = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationHistoryClient.List.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationHistoryClient.List.g.cs index f893af8..6e7f972 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationHistoryClient.List.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationHistoryClient.List.g.cs @@ -16,11 +16,13 @@ public partial interface IAnnotationHistoryClient /// /// /// + /// 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> ListAsync( int? annotation = default, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationHistoryClient.ListForProject.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationHistoryClient.ListForProject.g.cs index 5de948e..a47be32 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationHistoryClient.ListForProject.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationHistoryClient.ListForProject.g.cs @@ -17,12 +17,14 @@ public partial interface IAnnotationHistoryClient /// /// /// + /// 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 ListForProjectAsync( int id, int? page = default, int? pageSize = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationHistoryClient.Retrieve.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationHistoryClient.Retrieve.g.cs index ff58f74..eddcdd5 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationHistoryClient.Retrieve.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationHistoryClient.Retrieve.g.cs @@ -15,10 +15,12 @@ public partial interface IAnnotationHistoryClient /// Get one annotation history item by ID with full result. Used when FIT-720 lazy load is on and the user clicks a stubbed history item to hydrate it. /// /// + /// 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 RetrieveAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationHistoryClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationHistoryClient.g.cs index 30cae7c..2b2b901 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationHistoryClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationHistoryClient.g.cs @@ -33,6 +33,11 @@ public partial interface IAnnotationHistoryClient : global::System.IDisposable /// public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationReviews2Client.Create.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationReviews2Client.Create.g.cs index 04e54ae..d4de7fd 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationReviews2Client.Create.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationReviews2Client.Create.g.cs @@ -16,12 +16,14 @@ public partial interface IAnnotationReviews2Client /// /// /// + /// 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 CreateAsync( global::LabelStudio.AnnotationReviewRequest request, bool? asyncPostprocess = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Create review
@@ -47,6 +49,7 @@ public partial interface IAnnotationReviews2Client /// /// /// + /// 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 CreateAsync( @@ -58,6 +61,7 @@ public partial interface IAnnotationReviews2Client bool? removeFromQueue = default, object? result = default, global::System.DateTime? startedAt = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationReviews2Client.Delete.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationReviews2Client.Delete.g.cs index 3a419d4..bd7f0df 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationReviews2Client.Delete.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationReviews2Client.Delete.g.cs @@ -15,10 +15,12 @@ public partial interface IAnnotationReviews2Client /// Delete a review by ID. Only allowed for organizations with reviewing features enabled. ///
/// + /// 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 DeleteAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationReviews2Client.Get.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationReviews2Client.Get.g.cs index 95d3887..3a95bbb 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationReviews2Client.Get.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationReviews2Client.Get.g.cs @@ -15,10 +15,12 @@ public partial interface IAnnotationReviews2Client /// Retrieve a specific review by ID for an annotation. Only allowed for organizations with reviewing features enabled. /// /// + /// 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 GetAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationReviews2Client.List.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationReviews2Client.List.g.cs index 453042e..4ce361a 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationReviews2Client.List.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationReviews2Client.List.g.cs @@ -17,12 +17,14 @@ public partial interface IAnnotationReviews2Client /// /// /// + /// 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> ListAsync( int? annotation = default, int? annotationTaskProject = default, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationReviews2Client.Update.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationReviews2Client.Update.g.cs index 0ef0826..0d4e830 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationReviews2Client.Update.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationReviews2Client.Update.g.cs @@ -16,12 +16,14 @@ public partial interface IAnnotationReviews2Client /// /// /// + /// 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 UpdateAsync( int id, global::LabelStudio.PatchedAnnotationReviewRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Update review
@@ -47,6 +49,7 @@ public partial interface IAnnotationReviews2Client /// /// /// + /// 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 UpdateAsync( @@ -58,6 +61,7 @@ public partial interface IAnnotationReviews2Client bool? removeFromQueue = default, object? result = default, global::System.DateTime? startedAt = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationReviews2Client.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationReviews2Client.g.cs index bacc7dd..13115b4 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationReviews2Client.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationReviews2Client.g.cs @@ -33,6 +33,11 @@ public partial interface IAnnotationReviews2Client : global::System.IDisposable ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationReviewsClient.ApiAnnotationReviewsUpdate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationReviewsClient.ApiAnnotationReviewsUpdate.g.cs index 8805bfb..5c09fc6 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationReviewsClient.ApiAnnotationReviewsUpdate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationReviewsClient.ApiAnnotationReviewsUpdate.g.cs @@ -16,12 +16,14 @@ public partial interface IAnnotationReviewsClient /// /// /// + /// 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 ApiAnnotationReviewsUpdateAsync( int id, global::LabelStudio.AnnotationReviewRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Put review
@@ -47,6 +49,7 @@ public partial interface IAnnotationReviewsClient /// /// /// + /// 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 ApiAnnotationReviewsUpdateAsync( @@ -58,6 +61,7 @@ public partial interface IAnnotationReviewsClient bool? removeFromQueue = default, object? result = default, global::System.DateTime? startedAt = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationReviewsClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationReviewsClient.g.cs index 3e1af93..1be32ac 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationReviewsClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationReviewsClient.g.cs @@ -33,6 +33,11 @@ public partial interface IAnnotationReviewsClient : global::System.IDisposable ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationsClient.Create.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationsClient.Create.g.cs index 7bec3bb..94bf976 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationsClient.Create.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationsClient.Create.g.cs @@ -23,12 +23,14 @@ public partial interface IAnnotationsClient /// /// /// + /// 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 CreateAsync( int id, global::LabelStudio.ApiTasksAnnotationsCreateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Create annotation
@@ -74,6 +76,7 @@ public partial interface IAnnotationsClient /// /// User skipped the task /// + /// 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 CreateAsync( @@ -86,6 +89,7 @@ public partial interface IAnnotationsClient int? task = default, int? updatedBy = default, bool? wasCancelled = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationsClient.CreateBulk.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationsClient.CreateBulk.g.cs index 2306187..91892bc 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationsClient.CreateBulk.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationsClient.CreateBulk.g.cs @@ -9,11 +9,13 @@ public partial interface IAnnotationsClient /// Create multiple annotations at once ///
/// + /// 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> CreateBulkAsync( global::LabelStudio.AnnotationBulkSerializerWithSelectedItemsRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Bulk create annotations
@@ -77,6 +79,7 @@ public partial interface IAnnotationsClient /// /// User skipped the task /// + /// 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> CreateBulkAsync( @@ -98,6 +101,7 @@ public partial interface IAnnotationsClient global::System.Collections.Generic.IList? tasks = default, int? updatedBy = default, bool? wasCancelled = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationsClient.Delete.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationsClient.Delete.g.cs index 1899911..9c5bb25 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationsClient.Delete.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationsClient.Delete.g.cs @@ -9,10 +9,12 @@ public partial interface IAnnotationsClient /// Delete an annotation. This action can't be undone! ///
/// + /// 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 DeleteAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationsClient.DeleteBulk.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationsClient.DeleteBulk.g.cs index 726f70a..737992d 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationsClient.DeleteBulk.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationsClient.DeleteBulk.g.cs @@ -9,11 +9,13 @@ public partial interface IAnnotationsClient /// Delete multiple annotations by their IDs. The deletion is processed synchronously. Returns the count of deleted annotations in the response. /// /// + /// 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 DeleteBulkAsync( global::LabelStudio.AnnotationBulkDeleteRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Bulk delete annotations by IDs
@@ -23,11 +25,13 @@ public partial interface IAnnotationsClient /// List of annotation IDs 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 DeleteBulkAsync( global::System.Collections.Generic.IList ids, int project, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationsClient.Get.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationsClient.Get.g.cs index b40dd02..ddfa5cb 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationsClient.Get.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationsClient.Get.g.cs @@ -9,10 +9,12 @@ public partial interface IAnnotationsClient /// Retrieve a specific annotation for a task using the annotation result ID. ///
/// + /// 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 GetAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationsClient.List.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationsClient.List.g.cs index 5d76100..20c7478 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationsClient.List.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationsClient.List.g.cs @@ -10,11 +10,13 @@ public partial interface IAnnotationsClient /// /// /// + /// 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> ListAsync( int id, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationsClient.Update.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationsClient.Update.g.cs index f583ecf..8a1833c 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationsClient.Update.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationsClient.Update.g.cs @@ -10,12 +10,14 @@ public partial interface IAnnotationsClient /// /// /// + /// 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 UpdateAsync( int id, global::LabelStudio.ApiAnnotationsPartialUpdateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Update annotation
@@ -48,6 +50,7 @@ public partial interface IAnnotationsClient /// /// User skipped the task /// + /// 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 UpdateAsync( @@ -60,6 +63,7 @@ public partial interface IAnnotationsClient int? task = default, int? updatedBy = default, bool? wasCancelled = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationsClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationsClient.g.cs index 6c98bb6..c6ef953 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationsClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IAnnotationsClient.g.cs @@ -33,6 +33,11 @@ public partial interface IAnnotationsClient : global::System.IDisposable ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IAwsClient.Logs.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IAwsClient.Logs.g.cs index 94334a1..b868c0e 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IAwsClient.Logs.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IAwsClient.Logs.g.cs @@ -20,6 +20,7 @@ public partial interface IAwsClient /// Default Value: 100 /// /// + /// 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 LogsAsync( @@ -27,6 +28,7 @@ public partial interface IAwsClient string? endDate = default, int? limit = default, string? startDate = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IAwsClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IAwsClient.g.cs index 5658f09..ef071da 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IAwsClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IAwsClient.g.cs @@ -33,6 +33,11 @@ public partial interface IAwsClient : global::System.IDisposable /// public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IBillingClient.Info.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IBillingClient.Info.g.cs index 8de86a2..1ee4e25 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IBillingClient.Info.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IBillingClient.Info.g.cs @@ -14,9 +14,11 @@ public partial interface IBillingClient /// </Card>
/// Retrieve billing checks and feature flags for the active 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 InfoAsync( + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IBillingClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IBillingClient.g.cs index f3c04af..4a09aa3 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IBillingClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.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::LabelStudio.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IBlueprints2Client.Create.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IBlueprints2Client.Create.g.cs index a29525a..a0907a4 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IBlueprints2Client.Create.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IBlueprints2Client.Create.g.cs @@ -9,11 +9,13 @@ public partial interface IBlueprints2Client /// Create a new blueprint /// /// + /// 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 CreateAsync( global::LabelStudio.BlueprintRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Create blueprint
@@ -33,6 +35,7 @@ public partial interface IBlueprints2Client /// /// Blueprint name. Must be between 3 and 50 characters long. /// + /// 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 CreateAsync( @@ -42,6 +45,7 @@ public partial interface IBlueprints2Client string? description = default, string? labelConfig = default, string? title = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IBlueprints2Client.Delete.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IBlueprints2Client.Delete.g.cs index 3830bb2..6451ad5 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IBlueprints2Client.Delete.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IBlueprints2Client.Delete.g.cs @@ -9,10 +9,12 @@ public partial interface IBlueprints2Client /// Delete a blueprint by ID ///
/// + /// 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 DeleteAsync( string id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IBlueprints2Client.Update.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IBlueprints2Client.Update.g.cs index 73de3d7..d02b0be 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IBlueprints2Client.Update.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IBlueprints2Client.Update.g.cs @@ -10,12 +10,14 @@ public partial interface IBlueprints2Client /// /// /// + /// 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 UpdateAsync( string id, global::LabelStudio.PatchedBlueprintUpdateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Update blueprint
@@ -31,6 +33,7 @@ public partial interface IBlueprints2Client /// /// Blueprint name. Must be between 3 and 50 characters long. /// + /// 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 UpdateAsync( @@ -38,6 +41,7 @@ public partial interface IBlueprints2Client global::System.Collections.Generic.IList taskIds, string? description = default, string? title = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IBlueprints2Client.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IBlueprints2Client.g.cs index 26e929b..d6f387e 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IBlueprints2Client.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IBlueprints2Client.g.cs @@ -33,6 +33,11 @@ public partial interface IBlueprints2Client : global::System.IDisposable ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IBlueprintsClient.ApiBlueprintsCreateProjectRetrieve.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IBlueprintsClient.ApiBlueprintsCreateProjectRetrieve.g.cs index 6bce836..e73d829 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IBlueprintsClient.ApiBlueprintsCreateProjectRetrieve.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IBlueprintsClient.ApiBlueprintsCreateProjectRetrieve.g.cs @@ -9,10 +9,12 @@ public partial interface IBlueprintsClient /// Create a new project from an existing blueprint. On success, user is redirected to the new project with a 302. /// /// + /// 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 ApiBlueprintsCreateProjectRetrieveAsync( string shareId, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IBlueprintsClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IBlueprintsClient.g.cs index ad5d65c..5b2edd7 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IBlueprintsClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IBlueprintsClient.g.cs @@ -33,6 +33,11 @@ public partial interface IBlueprintsClient : global::System.IDisposable /// public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IComments2Client.Create.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IComments2Client.Create.g.cs index 0b596e5..cc71440 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IComments2Client.Create.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IComments2Client.Create.g.cs @@ -16,12 +16,14 @@ public partial interface IComments2Client /// /// /// + /// 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 CreateAsync( global::LabelStudio.CommentRequest request, bool? expandCreatedBy = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Create comment
@@ -48,6 +50,7 @@ public partial interface IComments2Client /// /// Reviewer or annotator comment /// + /// 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 CreateAsync( @@ -58,6 +61,7 @@ public partial interface IComments2Client bool? isResolved = default, object? regionRef = default, string? text = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IComments2Client.Delete.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IComments2Client.Delete.g.cs index c2f97ff..4bfc4b3 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IComments2Client.Delete.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IComments2Client.Delete.g.cs @@ -16,11 +16,13 @@ public partial interface IComments2Client ///
/// /// + /// 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 DeleteAsync( string id, bool? expandCreatedBy = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IComments2Client.Export.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IComments2Client.Export.g.cs index 180eab7..5bec091 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IComments2Client.Export.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IComments2Client.Export.g.cs @@ -22,6 +22,7 @@ public partial interface IComments2Client /// /// /// + /// 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 ExportAsync( @@ -31,6 +32,7 @@ public partial interface IComments2Client bool? expandCreatedBy = default, string? projects = default, string? tz = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IComments2Client.Get.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IComments2Client.Get.g.cs index 8eb8163..2e61dca 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IComments2Client.Get.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IComments2Client.Get.g.cs @@ -16,11 +16,13 @@ public partial interface IComments2Client /// /// /// + /// 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 GetAsync( string id, bool? expandCreatedBy = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IComments2Client.List.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IComments2Client.List.g.cs index 15e66bf..45af899 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IComments2Client.List.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IComments2Client.List.g.cs @@ -22,6 +22,7 @@ public partial interface IComments2Client /// /// /// + /// 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> ListAsync( @@ -31,6 +32,7 @@ public partial interface IComments2Client bool? expandCreatedBy = default, string? ordering = default, string? projects = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IComments2Client.Update.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IComments2Client.Update.g.cs index 448ea00..a537b23 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IComments2Client.Update.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IComments2Client.Update.g.cs @@ -17,6 +17,7 @@ public partial interface IComments2Client /// /// /// + /// 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 UpdateAsync( @@ -24,6 +25,7 @@ public partial interface IComments2Client global::LabelStudio.PatchedCommentRequest request, bool? expandCreatedBy = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Update comment
@@ -51,6 +53,7 @@ public partial interface IComments2Client /// /// Reviewer or annotator comment /// + /// 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 UpdateAsync( @@ -62,6 +65,7 @@ public partial interface IComments2Client bool? isResolved = default, object? regionRef = default, string? text = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IComments2Client.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IComments2Client.g.cs index e73e24a..e48f06a 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IComments2Client.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IComments2Client.g.cs @@ -33,6 +33,11 @@ public partial interface IComments2Client : global::System.IDisposable ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ICommentsClient.ApiCommentsUpdate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ICommentsClient.ApiCommentsUpdate.g.cs index 1429a8a..6fc9756 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ICommentsClient.ApiCommentsUpdate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ICommentsClient.ApiCommentsUpdate.g.cs @@ -17,6 +17,7 @@ public partial interface ICommentsClient /// /// /// + /// 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 ApiCommentsUpdateAsync( @@ -24,6 +25,7 @@ public partial interface ICommentsClient global::LabelStudio.CommentRequest request, bool? expandCreatedBy = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Put comment
@@ -51,6 +53,7 @@ public partial interface ICommentsClient /// /// Reviewer or annotator comment /// + /// 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 ApiCommentsUpdateAsync( @@ -62,6 +65,7 @@ public partial interface ICommentsClient bool? isResolved = default, object? regionRef = default, string? text = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ICommentsClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ICommentsClient.g.cs index 0417dae..6e8a071 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ICommentsClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ICommentsClient.g.cs @@ -33,6 +33,11 @@ public partial interface ICommentsClient : global::System.IDisposable ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IDataExplorerClient.ApiDatasetsColumnsRetrieve.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IDataExplorerClient.ApiDatasetsColumnsRetrieve.g.cs index 36d3b75..a16979c 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IDataExplorerClient.ApiDatasetsColumnsRetrieve.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IDataExplorerClient.ApiDatasetsColumnsRetrieve.g.cs @@ -9,10 +9,12 @@ public partial interface IDataExplorerClient /// Retrieve the data explorer columns available for a specific Dataset. /// /// + /// 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 ApiDatasetsColumnsRetrieveAsync( int? dataset = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IDataExplorerClient.ApiDatasetsImportCreate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IDataExplorerClient.ApiDatasetsImportCreate.g.cs index 2b7b742..f2e4174 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IDataExplorerClient.ApiDatasetsImportCreate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IDataExplorerClient.ApiDatasetsImportCreate.g.cs @@ -15,6 +15,7 @@ public partial interface IDataExplorerClient /// /// /// + /// 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 ApiDatasetsImportCreateAsync( @@ -24,6 +25,7 @@ public partial interface IDataExplorerClient object? included = default, int? project = default, int? view = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IDataExplorerClient.ApiDatasetsTasksMetadataRetrieve.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IDataExplorerClient.ApiDatasetsTasksMetadataRetrieve.g.cs index 7f52c13..a75185a 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IDataExplorerClient.ApiDatasetsTasksMetadataRetrieve.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IDataExplorerClient.ApiDatasetsTasksMetadataRetrieve.g.cs @@ -12,12 +12,14 @@ public partial interface IDataExplorerClient /// /// /// + /// 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 ApiDatasetsTasksMetadataRetrieveAsync( string? candidateTaskId = default, int? dataset = default, string? vectordbId = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IDataExplorerClient.ApiDatasetsTasksRetrieve.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IDataExplorerClient.ApiDatasetsTasksRetrieve.g.cs index c0e755d..9483669 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IDataExplorerClient.ApiDatasetsTasksRetrieve.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IDataExplorerClient.ApiDatasetsTasksRetrieve.g.cs @@ -15,6 +15,7 @@ public partial interface IDataExplorerClient /// /// /// + /// 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 ApiDatasetsTasksRetrieveAsync( @@ -24,6 +25,7 @@ public partial interface IDataExplorerClient int? page = default, int? pageSize = default, int? view = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IDataExplorerClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IDataExplorerClient.g.cs index 7d39beb..f6017ce 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IDataExplorerClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IDataExplorerClient.g.cs @@ -33,6 +33,11 @@ public partial interface IDataExplorerClient : global::System.IDisposable /// public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IDataManagerClient.ApiDmActionsFormRetrieve.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IDataManagerClient.ApiDmActionsFormRetrieve.g.cs index d82e974..8f1015e 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IDataManagerClient.ApiDmActionsFormRetrieve.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IDataManagerClient.ApiDmActionsFormRetrieve.g.cs @@ -10,11 +10,13 @@ public partial interface IDataManagerClient /// /// /// + /// 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 ApiDmActionsFormRetrieveAsync( string actionId, int project, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IDataManagerClient.ApiDmProjectRetrieve.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IDataManagerClient.ApiDmProjectRetrieve.g.cs index 08c1a8b..e4f8be6 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IDataManagerClient.ApiDmProjectRetrieve.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IDataManagerClient.ApiDmProjectRetrieve.g.cs @@ -8,9 +8,11 @@ public partial interface IDataManagerClient /// Get project state
/// Retrieve the project state for the data manager. /// + /// 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 ApiDmProjectRetrieveAsync( + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IDataManagerClient.ApiDmViewsUpdate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IDataManagerClient.ApiDmViewsUpdate.g.cs index 1ace255..1c2b73d 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IDataManagerClient.ApiDmViewsUpdate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IDataManagerClient.ApiDmViewsUpdate.g.cs @@ -10,12 +10,14 @@ public partial interface IDataManagerClient /// /// /// + /// 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 ApiDmViewsUpdateAsync( string id, global::LabelStudio.ApiDmViewsUpdateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Put view
@@ -28,12 +30,14 @@ public partial interface IDataManagerClient /// /// Project ID /// + /// 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 ApiDmViewsUpdateAsync( string id, global::LabelStudio.ApiDmViewsUpdateRequestData? data = default, int? project = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IDataManagerClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IDataManagerClient.g.cs index bf8ddf0..474cf8a 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IDataManagerClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IDataManagerClient.g.cs @@ -33,6 +33,11 @@ public partial interface IDataManagerClient : global::System.IDisposable ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageAzureClient.ApiDatasetStoragesAzureCheckForRecordsCreate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageAzureClient.ApiDatasetStoragesAzureCheckForRecordsCreate.g.cs index 42442ed..fdfe1f6 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageAzureClient.ApiDatasetStoragesAzureCheckForRecordsCreate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageAzureClient.ApiDatasetStoragesAzureCheckForRecordsCreate.g.cs @@ -9,11 +9,13 @@ public partial interface IDatasetStorageAzureClient /// Checks for existence of records matching the file pattern in the bucket/prefix /// /// + /// 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 ApiDatasetStoragesAzureCheckForRecordsCreateAsync( global::LabelStudio.AzureDatasetStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Check for records given the file pattern
@@ -87,6 +89,7 @@ public partial interface IDatasetStorageAzureClient /// /// Interpret objects as BLOBs and generate URLs /// + /// 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 ApiDatasetStoragesAzureCheckForRecordsCreateAsync( @@ -111,6 +114,7 @@ public partial interface IDatasetStorageAzureClient string? title = default, string? traceback = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageAzureClient.ApiDatasetStoragesAzureColumnsRetrieve.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageAzureClient.ApiDatasetStoragesAzureColumnsRetrieve.g.cs index fc62f20..839f51b 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageAzureClient.ApiDatasetStoragesAzureColumnsRetrieve.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageAzureClient.ApiDatasetStoragesAzureColumnsRetrieve.g.cs @@ -9,10 +9,12 @@ public partial interface IDatasetStorageAzureClient /// Retrieves column names from users JSON/blob data in bucket ///
/// + /// 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 ApiDatasetStoragesAzureColumnsRetrieveAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageAzureClient.ApiDatasetStoragesAzureCreate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageAzureClient.ApiDatasetStoragesAzureCreate.g.cs index 8da21c3..7c184f8 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageAzureClient.ApiDatasetStoragesAzureCreate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageAzureClient.ApiDatasetStoragesAzureCreate.g.cs @@ -9,11 +9,13 @@ public partial interface IDatasetStorageAzureClient /// Create a new Azure import storage connection. /// /// + /// 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 ApiDatasetStoragesAzureCreateAsync( global::LabelStudio.AzureDatasetStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Create import storage
@@ -87,6 +89,7 @@ public partial interface IDatasetStorageAzureClient /// /// Interpret objects as BLOBs and generate URLs /// + /// 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 ApiDatasetStoragesAzureCreateAsync( @@ -111,6 +114,7 @@ public partial interface IDatasetStorageAzureClient string? title = default, string? traceback = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageAzureClient.ApiDatasetStoragesAzureDestroy.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageAzureClient.ApiDatasetStoragesAzureDestroy.g.cs index a13377b..20ce370 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageAzureClient.ApiDatasetStoragesAzureDestroy.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageAzureClient.ApiDatasetStoragesAzureDestroy.g.cs @@ -9,10 +9,12 @@ public partial interface IDatasetStorageAzureClient /// Delete a specific Azure import storage connection. ///
/// + /// 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 ApiDatasetStoragesAzureDestroyAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageAzureClient.ApiDatasetStoragesAzureList.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageAzureClient.ApiDatasetStoragesAzureList.g.cs index 4238ef8..85b8d9b 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageAzureClient.ApiDatasetStoragesAzureList.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageAzureClient.ApiDatasetStoragesAzureList.g.cs @@ -10,11 +10,13 @@ public partial interface IDatasetStorageAzureClient /// /// /// + /// 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> ApiDatasetStoragesAzureListAsync( int? dataset = default, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageAzureClient.ApiDatasetStoragesAzurePartialUpdate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageAzureClient.ApiDatasetStoragesAzurePartialUpdate.g.cs index efaaf29..4e2d048 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageAzureClient.ApiDatasetStoragesAzurePartialUpdate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageAzureClient.ApiDatasetStoragesAzurePartialUpdate.g.cs @@ -10,12 +10,14 @@ public partial interface IDatasetStorageAzureClient /// /// /// + /// 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 ApiDatasetStoragesAzurePartialUpdateAsync( int id, global::LabelStudio.PatchedAzureDatasetStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Update import storage
@@ -90,6 +92,7 @@ public partial interface IDatasetStorageAzureClient /// /// Interpret objects as BLOBs and generate URLs /// + /// 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 ApiDatasetStoragesAzurePartialUpdateAsync( @@ -115,6 +118,7 @@ public partial interface IDatasetStorageAzureClient string? title = default, string? traceback = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageAzureClient.ApiDatasetStoragesAzureRetrieve.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageAzureClient.ApiDatasetStoragesAzureRetrieve.g.cs index a2c59a3..97b9f10 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageAzureClient.ApiDatasetStoragesAzureRetrieve.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageAzureClient.ApiDatasetStoragesAzureRetrieve.g.cs @@ -9,10 +9,12 @@ public partial interface IDatasetStorageAzureClient /// Get a specific Azure import storage connection. ///
/// + /// 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 ApiDatasetStoragesAzureRetrieveAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageAzureClient.ApiDatasetStoragesAzureSyncCreate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageAzureClient.ApiDatasetStoragesAzureSyncCreate.g.cs index 0950d4a..e6fa2f6 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageAzureClient.ApiDatasetStoragesAzureSyncCreate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageAzureClient.ApiDatasetStoragesAzureSyncCreate.g.cs @@ -10,12 +10,14 @@ public partial interface IDatasetStorageAzureClient /// /// /// + /// 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 ApiDatasetStoragesAzureSyncCreateAsync( int id, global::LabelStudio.AzureDatasetStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Sync import storage
@@ -90,6 +92,7 @@ public partial interface IDatasetStorageAzureClient /// /// Interpret objects as BLOBs and generate URLs /// + /// 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 ApiDatasetStoragesAzureSyncCreateAsync( @@ -115,6 +118,7 @@ public partial interface IDatasetStorageAzureClient string? title = default, string? traceback = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageAzureClient.ApiDatasetStoragesAzureValidateCreate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageAzureClient.ApiDatasetStoragesAzureValidateCreate.g.cs index 9b8a63f..f245c00 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageAzureClient.ApiDatasetStoragesAzureValidateCreate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageAzureClient.ApiDatasetStoragesAzureValidateCreate.g.cs @@ -9,11 +9,13 @@ public partial interface IDatasetStorageAzureClient /// Validate a specific Azure import storage connection. ///
/// + /// 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 ApiDatasetStoragesAzureValidateCreateAsync( global::LabelStudio.AzureDatasetStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Validate import storage
@@ -87,6 +89,7 @@ public partial interface IDatasetStorageAzureClient /// /// Interpret objects as BLOBs and generate URLs /// + /// 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 ApiDatasetStoragesAzureValidateCreateAsync( @@ -111,6 +114,7 @@ public partial interface IDatasetStorageAzureClient string? title = default, string? traceback = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageAzureClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageAzureClient.g.cs index 96eb2b8..e09a86d 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageAzureClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageAzureClient.g.cs @@ -33,6 +33,11 @@ public partial interface IDatasetStorageAzureClient : global::System.IDisposable ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageGcsClient.ApiDatasetStoragesGcsCheckForRecordsCreate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageGcsClient.ApiDatasetStoragesGcsCheckForRecordsCreate.g.cs index b720ce3..d4b2ed7 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageGcsClient.ApiDatasetStoragesGcsCheckForRecordsCreate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageGcsClient.ApiDatasetStoragesGcsCheckForRecordsCreate.g.cs @@ -9,11 +9,13 @@ public partial interface IDatasetStorageGcsClient /// Checks for existence of records matching the file pattern in the bucket/prefix /// /// + /// 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 ApiDatasetStoragesGcsCheckForRecordsCreateAsync( global::LabelStudio.GCSDatasetStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Check for records given the file pattern
@@ -87,6 +89,7 @@ public partial interface IDatasetStorageGcsClient /// /// Interpret objects as BLOBs and generate URLs /// + /// 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 ApiDatasetStoragesGcsCheckForRecordsCreateAsync( @@ -111,6 +114,7 @@ public partial interface IDatasetStorageGcsClient string? title = default, string? traceback = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageGcsClient.ApiDatasetStoragesGcsColumnsRetrieve.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageGcsClient.ApiDatasetStoragesGcsColumnsRetrieve.g.cs index 4bdb641..1573053 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageGcsClient.ApiDatasetStoragesGcsColumnsRetrieve.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageGcsClient.ApiDatasetStoragesGcsColumnsRetrieve.g.cs @@ -9,10 +9,12 @@ public partial interface IDatasetStorageGcsClient /// Retrieves column names from users JSON/blob data in bucket ///
/// + /// 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 ApiDatasetStoragesGcsColumnsRetrieveAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageGcsClient.ApiDatasetStoragesGcsCreate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageGcsClient.ApiDatasetStoragesGcsCreate.g.cs index c6dc725..fdf3c16 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageGcsClient.ApiDatasetStoragesGcsCreate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageGcsClient.ApiDatasetStoragesGcsCreate.g.cs @@ -9,11 +9,13 @@ public partial interface IDatasetStorageGcsClient /// Create a new GCS import storage connection. /// /// + /// 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 ApiDatasetStoragesGcsCreateAsync( global::LabelStudio.GCSDatasetStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Create import storage
@@ -87,6 +89,7 @@ public partial interface IDatasetStorageGcsClient /// /// Interpret objects as BLOBs and generate URLs /// + /// 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 ApiDatasetStoragesGcsCreateAsync( @@ -111,6 +114,7 @@ public partial interface IDatasetStorageGcsClient string? title = default, string? traceback = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageGcsClient.ApiDatasetStoragesGcsDestroy.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageGcsClient.ApiDatasetStoragesGcsDestroy.g.cs index 5531a01..865a540 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageGcsClient.ApiDatasetStoragesGcsDestroy.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageGcsClient.ApiDatasetStoragesGcsDestroy.g.cs @@ -9,10 +9,12 @@ public partial interface IDatasetStorageGcsClient /// Delete a specific GCS import storage connection. ///
/// + /// 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 ApiDatasetStoragesGcsDestroyAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageGcsClient.ApiDatasetStoragesGcsList.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageGcsClient.ApiDatasetStoragesGcsList.g.cs index a70e80a..d06d188 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageGcsClient.ApiDatasetStoragesGcsList.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageGcsClient.ApiDatasetStoragesGcsList.g.cs @@ -10,11 +10,13 @@ public partial interface IDatasetStorageGcsClient /// /// /// + /// 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> ApiDatasetStoragesGcsListAsync( int? dataset = default, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageGcsClient.ApiDatasetStoragesGcsPartialUpdate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageGcsClient.ApiDatasetStoragesGcsPartialUpdate.g.cs index 555001c..d06d355 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageGcsClient.ApiDatasetStoragesGcsPartialUpdate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageGcsClient.ApiDatasetStoragesGcsPartialUpdate.g.cs @@ -10,12 +10,14 @@ public partial interface IDatasetStorageGcsClient /// /// /// + /// 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 ApiDatasetStoragesGcsPartialUpdateAsync( int id, global::LabelStudio.PatchedGCSDatasetStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Update import storage
@@ -90,6 +92,7 @@ public partial interface IDatasetStorageGcsClient /// /// Interpret objects as BLOBs and generate URLs /// + /// 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 ApiDatasetStoragesGcsPartialUpdateAsync( @@ -115,6 +118,7 @@ public partial interface IDatasetStorageGcsClient string? title = default, string? traceback = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageGcsClient.ApiDatasetStoragesGcsRetrieve.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageGcsClient.ApiDatasetStoragesGcsRetrieve.g.cs index 69d09c7..273dca6 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageGcsClient.ApiDatasetStoragesGcsRetrieve.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageGcsClient.ApiDatasetStoragesGcsRetrieve.g.cs @@ -9,10 +9,12 @@ public partial interface IDatasetStorageGcsClient /// Get a specific GCS import storage connection. ///
/// + /// 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 ApiDatasetStoragesGcsRetrieveAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageGcsClient.ApiDatasetStoragesGcsSyncCreate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageGcsClient.ApiDatasetStoragesGcsSyncCreate.g.cs index 003e098..9801b08 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageGcsClient.ApiDatasetStoragesGcsSyncCreate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageGcsClient.ApiDatasetStoragesGcsSyncCreate.g.cs @@ -10,12 +10,14 @@ public partial interface IDatasetStorageGcsClient /// /// /// + /// 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 ApiDatasetStoragesGcsSyncCreateAsync( int id, global::LabelStudio.GCSDatasetStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Sync import storage
@@ -90,6 +92,7 @@ public partial interface IDatasetStorageGcsClient /// /// Interpret objects as BLOBs and generate URLs /// + /// 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 ApiDatasetStoragesGcsSyncCreateAsync( @@ -115,6 +118,7 @@ public partial interface IDatasetStorageGcsClient string? title = default, string? traceback = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageGcsClient.ApiDatasetStoragesGcsValidateCreate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageGcsClient.ApiDatasetStoragesGcsValidateCreate.g.cs index 5960953..749c8ee 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageGcsClient.ApiDatasetStoragesGcsValidateCreate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageGcsClient.ApiDatasetStoragesGcsValidateCreate.g.cs @@ -9,11 +9,13 @@ public partial interface IDatasetStorageGcsClient /// Validate a specific GCS import storage connection. ///
/// + /// 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 ApiDatasetStoragesGcsValidateCreateAsync( global::LabelStudio.GCSDatasetStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Validate import storage
@@ -87,6 +89,7 @@ public partial interface IDatasetStorageGcsClient /// /// Interpret objects as BLOBs and generate URLs /// + /// 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 ApiDatasetStoragesGcsValidateCreateAsync( @@ -111,6 +114,7 @@ public partial interface IDatasetStorageGcsClient string? title = default, string? traceback = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageGcsClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageGcsClient.g.cs index 0604881..3e99e90 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageGcsClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageGcsClient.g.cs @@ -33,6 +33,11 @@ public partial interface IDatasetStorageGcsClient : global::System.IDisposable ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageS3Client.ApiDatasetStoragesS3CheckForRecordsCreate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageS3Client.ApiDatasetStoragesS3CheckForRecordsCreate.g.cs index c6a7836..c3c1f70 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageS3Client.ApiDatasetStoragesS3CheckForRecordsCreate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageS3Client.ApiDatasetStoragesS3CheckForRecordsCreate.g.cs @@ -9,11 +9,13 @@ public partial interface IDatasetStorageS3Client /// Checks for existence of records matching the file pattern in the bucket/prefix /// /// + /// 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 ApiDatasetStoragesS3CheckForRecordsCreateAsync( global::LabelStudio.S3DatasetStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Check for records given the file pattern
@@ -99,6 +101,7 @@ public partial interface IDatasetStorageS3Client /// /// Interpret objects as BLOBs and generate URLs /// + /// 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 ApiDatasetStoragesS3CheckForRecordsCreateAsync( @@ -127,6 +130,7 @@ public partial interface IDatasetStorageS3Client string? title = default, string? traceback = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageS3Client.ApiDatasetStoragesS3ColumnsRetrieve.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageS3Client.ApiDatasetStoragesS3ColumnsRetrieve.g.cs index c83120c..fbffd1e 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageS3Client.ApiDatasetStoragesS3ColumnsRetrieve.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageS3Client.ApiDatasetStoragesS3ColumnsRetrieve.g.cs @@ -9,10 +9,12 @@ public partial interface IDatasetStorageS3Client /// Retrieves column names from users JSON/blob data in bucket ///
/// + /// 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 ApiDatasetStoragesS3ColumnsRetrieveAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageS3Client.ApiDatasetStoragesS3Create.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageS3Client.ApiDatasetStoragesS3Create.g.cs index 1cfe597..fdd1cf1 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageS3Client.ApiDatasetStoragesS3Create.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageS3Client.ApiDatasetStoragesS3Create.g.cs @@ -9,11 +9,13 @@ public partial interface IDatasetStorageS3Client /// Create a new S3 import storage connection. /// /// + /// 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 ApiDatasetStoragesS3CreateAsync( global::LabelStudio.S3DatasetStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Create import storage
@@ -99,6 +101,7 @@ public partial interface IDatasetStorageS3Client /// /// Interpret objects as BLOBs and generate URLs /// + /// 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 ApiDatasetStoragesS3CreateAsync( @@ -127,6 +130,7 @@ public partial interface IDatasetStorageS3Client string? title = default, string? traceback = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageS3Client.ApiDatasetStoragesS3Destroy.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageS3Client.ApiDatasetStoragesS3Destroy.g.cs index 068fa64..e8dbd14 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageS3Client.ApiDatasetStoragesS3Destroy.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageS3Client.ApiDatasetStoragesS3Destroy.g.cs @@ -9,10 +9,12 @@ public partial interface IDatasetStorageS3Client /// Delete a specific S3 import storage connection. ///
/// + /// 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 ApiDatasetStoragesS3DestroyAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageS3Client.ApiDatasetStoragesS3List.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageS3Client.ApiDatasetStoragesS3List.g.cs index b17885a..653e8ec 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageS3Client.ApiDatasetStoragesS3List.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageS3Client.ApiDatasetStoragesS3List.g.cs @@ -10,11 +10,13 @@ public partial interface IDatasetStorageS3Client /// /// /// + /// 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> ApiDatasetStoragesS3ListAsync( int? dataset = default, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageS3Client.ApiDatasetStoragesS3PartialUpdate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageS3Client.ApiDatasetStoragesS3PartialUpdate.g.cs index fb403b9..6cf6ed4 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageS3Client.ApiDatasetStoragesS3PartialUpdate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageS3Client.ApiDatasetStoragesS3PartialUpdate.g.cs @@ -10,12 +10,14 @@ public partial interface IDatasetStorageS3Client /// /// /// + /// 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 ApiDatasetStoragesS3PartialUpdateAsync( int id, global::LabelStudio.PatchedS3DatasetStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Update import storage
@@ -102,6 +104,7 @@ public partial interface IDatasetStorageS3Client /// /// Interpret objects as BLOBs and generate URLs /// + /// 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 ApiDatasetStoragesS3PartialUpdateAsync( @@ -131,6 +134,7 @@ public partial interface IDatasetStorageS3Client string? title = default, string? traceback = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageS3Client.ApiDatasetStoragesS3Retrieve.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageS3Client.ApiDatasetStoragesS3Retrieve.g.cs index 251f929..49c9720 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageS3Client.ApiDatasetStoragesS3Retrieve.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageS3Client.ApiDatasetStoragesS3Retrieve.g.cs @@ -9,10 +9,12 @@ public partial interface IDatasetStorageS3Client /// Get a specific S3 import storage connection. ///
/// + /// 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 ApiDatasetStoragesS3RetrieveAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageS3Client.ApiDatasetStoragesS3SyncCreate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageS3Client.ApiDatasetStoragesS3SyncCreate.g.cs index bfe9c55..ea2fc10 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageS3Client.ApiDatasetStoragesS3SyncCreate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageS3Client.ApiDatasetStoragesS3SyncCreate.g.cs @@ -10,12 +10,14 @@ public partial interface IDatasetStorageS3Client /// /// /// + /// 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 ApiDatasetStoragesS3SyncCreateAsync( int id, global::LabelStudio.S3DatasetStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Sync import storage
@@ -102,6 +104,7 @@ public partial interface IDatasetStorageS3Client /// /// Interpret objects as BLOBs and generate URLs /// + /// 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 ApiDatasetStoragesS3SyncCreateAsync( @@ -131,6 +134,7 @@ public partial interface IDatasetStorageS3Client string? title = default, string? traceback = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageS3Client.ApiDatasetStoragesS3ValidateCreate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageS3Client.ApiDatasetStoragesS3ValidateCreate.g.cs index ead5b12..bea1116 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageS3Client.ApiDatasetStoragesS3ValidateCreate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageS3Client.ApiDatasetStoragesS3ValidateCreate.g.cs @@ -9,11 +9,13 @@ public partial interface IDatasetStorageS3Client /// Validate a specific S3 import storage connection. ///
/// + /// 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 ApiDatasetStoragesS3ValidateCreateAsync( global::LabelStudio.S3DatasetStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Validate import storage
@@ -99,6 +101,7 @@ public partial interface IDatasetStorageS3Client /// /// Interpret objects as BLOBs and generate URLs /// + /// 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 ApiDatasetStoragesS3ValidateCreateAsync( @@ -127,6 +130,7 @@ public partial interface IDatasetStorageS3Client string? title = default, string? traceback = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageS3Client.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageS3Client.g.cs index a359632..af4e691 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageS3Client.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetStorageS3Client.g.cs @@ -33,6 +33,11 @@ public partial interface IDatasetStorageS3Client : global::System.IDisposable ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetsClient.ApiDatasetsCreate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetsClient.ApiDatasetsCreate.g.cs index 4c030db..17e129f 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetsClient.ApiDatasetsCreate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetsClient.ApiDatasetsCreate.g.cs @@ -9,11 +9,13 @@ public partial interface IDatasetsClient /// Create a new dataset. /// /// + /// 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 ApiDatasetsCreateAsync( global::LabelStudio.DatasetRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Create dataset
@@ -36,6 +38,7 @@ public partial interface IDatasetsClient /// /// Dataset name for weaviate 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 ApiDatasetsCreateAsync( @@ -46,6 +49,7 @@ public partial interface IDatasetsClient int? organization = default, int? totalEntities = default, string? vectorDbDatasetName = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetsClient.ApiDatasetsDestroy.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetsClient.ApiDatasetsDestroy.g.cs index b087796..853da1a 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetsClient.ApiDatasetsDestroy.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetsClient.ApiDatasetsDestroy.g.cs @@ -9,10 +9,12 @@ public partial interface IDatasetsClient /// Delete a dataset by ID ///
/// + /// 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 ApiDatasetsDestroyAsync( string id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetsClient.ApiDatasetsImportPartialUpdate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetsClient.ApiDatasetsImportPartialUpdate.g.cs index 5c1a08d..83bd74f 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetsClient.ApiDatasetsImportPartialUpdate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetsClient.ApiDatasetsImportPartialUpdate.g.cs @@ -10,11 +10,13 @@ public partial interface IDatasetsClient /// /// /// + /// 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 ApiDatasetsImportPartialUpdateAsync( int? jobId = default, string? signal = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetsClient.ApiDatasetsList.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetsClient.ApiDatasetsList.g.cs index 89bfb94..a680182 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetsClient.ApiDatasetsList.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetsClient.ApiDatasetsList.g.cs @@ -9,10 +9,12 @@ public partial interface IDatasetsClient /// List all datasets. /// /// + /// 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> ApiDatasetsListAsync( string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetsClient.ApiDatasetsMembersCreate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetsClient.ApiDatasetsMembersCreate.g.cs index 10ceb00..cbf7335 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetsClient.ApiDatasetsMembersCreate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetsClient.ApiDatasetsMembersCreate.g.cs @@ -10,12 +10,14 @@ public partial interface IDatasetsClient /// /// /// + /// 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 ApiDatasetsMembersCreateAsync( int id, global::LabelStudio.DatasetMemberRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Add dataset member
@@ -23,11 +25,13 @@ public partial interface IDatasetsClient ///
/// /// + /// 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 ApiDatasetsMembersCreateAsync( int id, int user, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetsClient.ApiDatasetsMembersDestroy.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetsClient.ApiDatasetsMembersDestroy.g.cs index 86743b4..0e08a57 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetsClient.ApiDatasetsMembersDestroy.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetsClient.ApiDatasetsMembersDestroy.g.cs @@ -10,11 +10,13 @@ public partial interface IDatasetsClient /// /// /// + /// 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 ApiDatasetsMembersDestroyAsync( int id, int? projectMember = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetsClient.ApiDatasetsMembersList.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetsClient.ApiDatasetsMembersList.g.cs index b4ddef2..a439f24 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetsClient.ApiDatasetsMembersList.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetsClient.ApiDatasetsMembersList.g.cs @@ -10,11 +10,13 @@ public partial interface IDatasetsClient /// /// /// + /// 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> ApiDatasetsMembersListAsync( int id, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetsClient.ApiDatasetsPartialUpdate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetsClient.ApiDatasetsPartialUpdate.g.cs index 57f52ff..1bd1dc3 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetsClient.ApiDatasetsPartialUpdate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetsClient.ApiDatasetsPartialUpdate.g.cs @@ -10,12 +10,14 @@ public partial interface IDatasetsClient /// /// /// + /// 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 ApiDatasetsPartialUpdateAsync( string id, global::LabelStudio.PatchedDatasetRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Update dataset
@@ -39,6 +41,7 @@ public partial interface IDatasetsClient /// /// Dataset name for weaviate 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 ApiDatasetsPartialUpdateAsync( @@ -50,6 +53,7 @@ public partial interface IDatasetsClient string? title = default, int? totalEntities = default, string? vectorDbDatasetName = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetsClient.ApiDatasetsRetrieve.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetsClient.ApiDatasetsRetrieve.g.cs index 7225137..24bdff9 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetsClient.ApiDatasetsRetrieve.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetsClient.ApiDatasetsRetrieve.g.cs @@ -9,10 +9,12 @@ public partial interface IDatasetsClient /// Retrieve a specific dataset. ///
/// + /// 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 ApiDatasetsRetrieveAsync( string id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetsClient.ApiDatasetsUpdate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetsClient.ApiDatasetsUpdate.g.cs index 950a0c6..8e21508 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetsClient.ApiDatasetsUpdate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetsClient.ApiDatasetsUpdate.g.cs @@ -10,12 +10,14 @@ public partial interface IDatasetsClient /// /// /// + /// 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 ApiDatasetsUpdateAsync( string id, global::LabelStudio.DatasetRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Put dataset
@@ -39,6 +41,7 @@ public partial interface IDatasetsClient /// /// Dataset name for weaviate 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 ApiDatasetsUpdateAsync( @@ -50,6 +53,7 @@ public partial interface IDatasetsClient int? organization = default, int? totalEntities = default, string? vectorDbDatasetName = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetsClient.ApiDatasetsViewsCreate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetsClient.ApiDatasetsViewsCreate.g.cs index 9d21abe..751c505 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetsClient.ApiDatasetsViewsCreate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetsClient.ApiDatasetsViewsCreate.g.cs @@ -9,11 +9,13 @@ public partial interface IDatasetsClient /// Create a view for a specific dataset. ///
/// + /// 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 ApiDatasetsViewsCreateAsync( global::LabelStudio.DatasetViewRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Create dataset view
@@ -38,6 +40,7 @@ public partial interface IDatasetsClient /// /// User who made this view /// + /// 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 ApiDatasetsViewsCreateAsync( @@ -48,6 +51,7 @@ public partial interface IDatasetsClient object? ordering = default, object? selectedItems = default, int? user = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetsClient.ApiDatasetsViewsDestroy.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetsClient.ApiDatasetsViewsDestroy.g.cs index 6ca870e..be35121 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetsClient.ApiDatasetsViewsDestroy.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetsClient.ApiDatasetsViewsDestroy.g.cs @@ -9,10 +9,12 @@ public partial interface IDatasetsClient /// Delete a specific view by ID. ///
/// + /// 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 ApiDatasetsViewsDestroyAsync( string id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetsClient.ApiDatasetsViewsList.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetsClient.ApiDatasetsViewsList.g.cs index bbf800f..e690af3 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetsClient.ApiDatasetsViewsList.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetsClient.ApiDatasetsViewsList.g.cs @@ -9,10 +9,12 @@ public partial interface IDatasetsClient /// List all views for a specific dataset. /// /// + /// 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> ApiDatasetsViewsListAsync( int? dataset = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetsClient.ApiDatasetsViewsPartialUpdate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetsClient.ApiDatasetsViewsPartialUpdate.g.cs index f51e33a..1cb8ee5 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetsClient.ApiDatasetsViewsPartialUpdate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetsClient.ApiDatasetsViewsPartialUpdate.g.cs @@ -10,12 +10,14 @@ public partial interface IDatasetsClient /// /// /// + /// 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 ApiDatasetsViewsPartialUpdateAsync( string id, global::LabelStudio.PatchedDatasetViewRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Update dataset view
@@ -41,6 +43,7 @@ public partial interface IDatasetsClient /// /// User who made this view /// + /// 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 ApiDatasetsViewsPartialUpdateAsync( @@ -52,6 +55,7 @@ public partial interface IDatasetsClient object? ordering = default, object? selectedItems = default, int? user = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetsClient.ApiDatasetsViewsResetDestroy.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetsClient.ApiDatasetsViewsResetDestroy.g.cs index eb88966..bacfb87 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetsClient.ApiDatasetsViewsResetDestroy.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetsClient.ApiDatasetsViewsResetDestroy.g.cs @@ -8,9 +8,11 @@ public partial interface IDatasetsClient /// Reset dataset views
/// Reset all views for a specific dataset. ///
+ /// 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 ApiDatasetsViewsResetDestroyAsync( + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetsClient.ApiDatasetsViewsRetrieve.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetsClient.ApiDatasetsViewsRetrieve.g.cs index 186f491..f50fd30 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetsClient.ApiDatasetsViewsRetrieve.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetsClient.ApiDatasetsViewsRetrieve.g.cs @@ -9,10 +9,12 @@ public partial interface IDatasetsClient /// Get the details about a specific view in the data manager /// /// + /// 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 ApiDatasetsViewsRetrieveAsync( string id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetsClient.ApiDatasetsViewsUpdate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetsClient.ApiDatasetsViewsUpdate.g.cs index 009ecd8..5951a0d 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetsClient.ApiDatasetsViewsUpdate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetsClient.ApiDatasetsViewsUpdate.g.cs @@ -10,12 +10,14 @@ public partial interface IDatasetsClient /// /// /// + /// 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 ApiDatasetsViewsUpdateAsync( string id, global::LabelStudio.DatasetViewRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Put dataset view
@@ -41,6 +43,7 @@ public partial interface IDatasetsClient /// /// User who made this view /// + /// 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 ApiDatasetsViewsUpdateAsync( @@ -52,6 +55,7 @@ public partial interface IDatasetsClient object? ordering = default, object? selectedItems = default, int? user = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetsClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetsClient.g.cs index 05a2b58..0416d96 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IDatasetsClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IDatasetsClient.g.cs @@ -33,6 +33,11 @@ public partial interface IDatasetsClient : global::System.IDisposable ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IDimensions2Client.CancelBackfill.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IDimensions2Client.CancelBackfill.g.cs index a7583b4..d75c05b 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IDimensions2Client.CancelBackfill.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IDimensions2Client.CancelBackfill.g.cs @@ -16,11 +16,13 @@ public partial interface IDimensions2Client /// /// /// + /// 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 CancelBackfillAsync( int? jobId = default, int? projectId = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IDimensions2Client.Create.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IDimensions2Client.Create.g.cs index 717aea1..5b9db71 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IDimensions2Client.Create.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IDimensions2Client.Create.g.cs @@ -16,12 +16,14 @@ public partial interface IDimensions2Client /// /// /// + /// 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 CreateAsync( int projectPk, global::LabelStudio.DimensionCreateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Create dimension
@@ -58,6 +60,7 @@ public partial interface IDimensions2Client /// /// Display order within the project /// + /// 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 CreateAsync( @@ -70,6 +73,7 @@ public partial interface IDimensions2Client object? metricParams = default, string? metricType = default, int? order = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IDimensions2Client.Delete.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IDimensions2Client.Delete.g.cs index af34d06..bd0812e 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IDimensions2Client.Delete.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IDimensions2Client.Delete.g.cs @@ -16,11 +16,13 @@ public partial interface IDimensions2Client ///
/// /// + /// 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 DeleteAsync( int id, int projectPk, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IDimensions2Client.Get.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IDimensions2Client.Get.g.cs index d05c92e..ffec3fb 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IDimensions2Client.Get.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IDimensions2Client.Get.g.cs @@ -16,11 +16,13 @@ public partial interface IDimensions2Client /// /// /// + /// 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 GetAsync( int id, int projectPk, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IDimensions2Client.GetBackfillStatus.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IDimensions2Client.GetBackfillStatus.g.cs index d953bde..cb62cd4 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IDimensions2Client.GetBackfillStatus.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IDimensions2Client.GetBackfillStatus.g.cs @@ -16,11 +16,13 @@ public partial interface IDimensions2Client /// /// /// + /// 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 GetBackfillStatusAsync( int? jobId = default, int? projectId = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IDimensions2Client.List.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IDimensions2Client.List.g.cs index 471e8a3..51b5b65 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IDimensions2Client.List.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IDimensions2Client.List.g.cs @@ -18,6 +18,7 @@ public partial interface IDimensions2Client /// /// /// + /// 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> ListAsync( @@ -25,6 +26,7 @@ public partial interface IDimensions2Client string? agreementMethodology = default, bool? isActive = default, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IDimensions2Client.ListBackfills.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IDimensions2Client.ListBackfills.g.cs index 835cdd3..3ba89fa 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IDimensions2Client.ListBackfills.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IDimensions2Client.ListBackfills.g.cs @@ -15,10 +15,12 @@ public partial interface IDimensions2Client /// Retrieve Agreement V2 backfill jobs for the authenticated user's active organization, ordered by most-recently created first. Supports page / page_size query params (default 50 per page, max 500). Requires administrator or owner role and the Agreement V2 feature flag. /// /// + /// 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> ListBackfillsAsync( string? status = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IDimensions2Client.TriggerBackfill.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IDimensions2Client.TriggerBackfill.g.cs index 6a90bd3..02fc9fa 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IDimensions2Client.TriggerBackfill.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IDimensions2Client.TriggerBackfill.g.cs @@ -19,11 +19,13 @@ public partial interface IDimensions2Client /// Requires administrator or owner role and the Agreement V2 feature flag. /// /// + /// 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 TriggerBackfillAsync( global::LabelStudio.AgreementV2BackfillTriggerRequestRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Trigger Agreement V2 backfill
@@ -48,12 +50,14 @@ public partial interface IDimensions2Client /// /// Backfill a single specific project. /// + /// 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 TriggerBackfillAsync( bool? allProjects = default, int? numProjects = default, int? projectId = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IDimensions2Client.Update.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IDimensions2Client.Update.g.cs index 7e7fa7b..565a116 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IDimensions2Client.Update.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IDimensions2Client.Update.g.cs @@ -17,6 +17,7 @@ public partial interface IDimensions2Client /// /// /// + /// 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 UpdateAsync( @@ -24,6 +25,7 @@ public partial interface IDimensions2Client int projectPk, global::LabelStudio.PatchedDimensionRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Update dimension
@@ -64,6 +66,7 @@ public partial interface IDimensions2Client /// /// Display order within the project /// + /// 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 UpdateAsync( @@ -78,6 +81,7 @@ public partial interface IDimensions2Client string? metricType = default, string? name = default, int? order = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IDimensions2Client.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IDimensions2Client.g.cs index a21dacf..ef61f0f 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IDimensions2Client.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IDimensions2Client.g.cs @@ -33,6 +33,11 @@ public partial interface IDimensions2Client : global::System.IDisposable ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IDimensionsClient.ApiProjectsDimensionsUpdate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IDimensionsClient.ApiProjectsDimensionsUpdate.g.cs index e19ddb7..048364d 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IDimensionsClient.ApiProjectsDimensionsUpdate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IDimensionsClient.ApiProjectsDimensionsUpdate.g.cs @@ -17,6 +17,7 @@ public partial interface IDimensionsClient /// /// /// + /// 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 ApiProjectsDimensionsUpdateAsync( @@ -24,6 +25,7 @@ public partial interface IDimensionsClient int projectPk, global::LabelStudio.DimensionRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Put dimension
@@ -64,6 +66,7 @@ public partial interface IDimensionsClient /// /// Display order within the project /// + /// 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 ApiProjectsDimensionsUpdateAsync( @@ -78,6 +81,7 @@ public partial interface IDimensionsClient object? metricParams = default, string? metricType = default, int? order = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IDimensionsClient.Get2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IDimensionsClient.Get2.g.cs index 3b84d59..ed0bb32 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IDimensionsClient.Get2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IDimensionsClient.Get2.g.cs @@ -18,6 +18,7 @@ public partial interface IDimensionsClient /// /// /// + /// 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 Get2Async( @@ -25,6 +26,7 @@ public partial interface IDimensionsClient global::LabelStudio.AgreementSelectionRequest selection, int taskPk, int? dimension = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IDimensionsClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IDimensionsClient.g.cs index 0d73979..e170fbe 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IDimensionsClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IDimensionsClient.g.cs @@ -33,6 +33,11 @@ public partial interface IDimensionsClient : global::System.IDisposable ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IExportClient.Convert.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IExportClient.Convert.g.cs index 687cf72..d0d2393 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IExportClient.Convert.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IExportClient.Convert.g.cs @@ -11,6 +11,7 @@ public partial interface IExportClient /// /// /// + /// 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 ConvertAsync( @@ -18,6 +19,7 @@ public partial interface IExportClient int id, global::LabelStudio.ExportConvertRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Export conversion
@@ -31,6 +33,7 @@ public partial interface IExportClient /// /// Export file format. /// + /// 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 ConvertAsync( @@ -38,6 +41,7 @@ public partial interface IExportClient int id, string exportType, bool? downloadResources = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IExportClient.Create.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IExportClient.Create.g.cs index 9888601..8e059c6 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IExportClient.Create.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IExportClient.Create.g.cs @@ -10,12 +10,14 @@ public partial interface IExportClient ///
/// /// + /// 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 CreateAsync( int id, global::LabelStudio.LseExportCreateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Create new export snapshot
@@ -39,6 +41,7 @@ public partial interface IExportClient /// /// /// + /// 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 CreateAsync( @@ -53,6 +56,7 @@ public partial interface IExportClient global::LabelStudio.Status7bfEnum? status = default, global::LabelStudio.LseTaskFilterOptionsRequest? taskFilterOptions = default, string? title = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IExportClient.Delete.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IExportClient.Delete.g.cs index 52419c2..01fefc8 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IExportClient.Delete.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IExportClient.Delete.g.cs @@ -10,11 +10,13 @@ public partial interface IExportClient ///
/// /// + /// 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 DeleteAsync( int exportPk, int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IExportClient.Download.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IExportClient.Download.g.cs index bb91996..5ddf629 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IExportClient.Download.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IExportClient.Download.g.cs @@ -16,12 +16,14 @@ public partial interface IExportClient /// /// /// + /// 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 DownloadAsync( int exportPk, int id, string? exportType = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IExportClient.Get.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IExportClient.Get.g.cs index d7ea007..ab5469a 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IExportClient.Get.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IExportClient.Get.g.cs @@ -10,11 +10,13 @@ public partial interface IExportClient ///
/// /// + /// 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 GetAsync( int exportPk, int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IExportClient.List.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IExportClient.List.g.cs index a4dd165..32af7ae 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IExportClient.List.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IExportClient.List.g.cs @@ -10,11 +10,13 @@ public partial interface IExportClient /// /// /// + /// 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> ListAsync( int id, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IExportClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IExportClient.g.cs index c867b29..f342986 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IExportClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IExportClient.g.cs @@ -33,6 +33,11 @@ public partial interface IExportClient : global::System.IDisposable /// public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IImportClient.Delete.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IImportClient.Delete.g.cs index 5abd286..fc19a3d 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IImportClient.Delete.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IImportClient.Delete.g.cs @@ -9,10 +9,12 @@ public partial interface IImportClient /// Delete a specific 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 DeleteAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IImportClient.DeleteMany.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IImportClient.DeleteMany.g.cs index 4c7064a..0176799 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IImportClient.DeleteMany.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IImportClient.DeleteMany.g.cs @@ -10,10 +10,12 @@ public partial interface IImportClient /// /// /// + /// 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 DeleteManyAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IImportClient.Download.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IImportClient.Download.g.cs index e7a89b6..81dc881 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IImportClient.Download.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IImportClient.Download.g.cs @@ -9,10 +9,12 @@ public partial interface IImportClient /// Download a specific 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 DownloadAsync( string filename, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IImportClient.Get.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IImportClient.Get.g.cs index 4eb5c40..affd8e2 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IImportClient.Get.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IImportClient.Get.g.cs @@ -9,10 +9,12 @@ public partial interface IImportClient /// Retrieve details about a specific 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 GetAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IImportClient.List.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IImportClient.List.g.cs index b49c155..4d04997 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IImportClient.List.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IImportClient.List.g.cs @@ -13,6 +13,7 @@ public partial interface IImportClient /// /// /// + /// 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> ListAsync( @@ -20,6 +21,7 @@ public partial interface IImportClient bool? all = default, global::System.Collections.Generic.IList? ids = default, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IImportClient.Update.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IImportClient.Update.g.cs index 9ce70f9..300025c 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IImportClient.Update.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IImportClient.Update.g.cs @@ -10,12 +10,14 @@ public partial interface IImportClient /// /// /// + /// 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 UpdateAsync( int id, global::LabelStudio.PatchedFileUploadRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Update file upload
@@ -24,12 +26,14 @@ public partial interface IImportClient /// /// /// + /// 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 UpdateAsync( int id, byte[]? file = default, string? filename = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IImportClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IImportClient.g.cs index 3dd4c2f..9d8146c 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IImportClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IImportClient.g.cs @@ -33,6 +33,11 @@ public partial interface IImportClient : global::System.IDisposable ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IJwtSettingsClient.Get.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IJwtSettingsClient.Get.g.cs index 13f5aab..268dd26 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IJwtSettingsClient.Get.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IJwtSettingsClient.Get.g.cs @@ -8,9 +8,11 @@ public partial interface IJwtSettingsClient /// Retrieve JWT Settings
/// Retrieve JWT settings for the currently active 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 GetAsync( + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IJwtSettingsClient.Update.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IJwtSettingsClient.Update.g.cs index a359212..9cba017 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IJwtSettingsClient.Update.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IJwtSettingsClient.Update.g.cs @@ -9,11 +9,13 @@ public partial interface IJwtSettingsClient /// Update JWT settings for the currently active 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 UpdateAsync( global::LabelStudio.LSEJWTSettingsRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Update JWT Settings
@@ -26,12 +28,14 @@ public partial interface IJwtSettingsClient /// /// Enable legacy API token authentication for this 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 UpdateAsync( int apiTokenTtlDays, bool? apiTokensEnabled = default, bool? legacyApiTokensEnabled = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IJwtSettingsClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IJwtSettingsClient.g.cs index 82d8469..0568a5a 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IJwtSettingsClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IJwtSettingsClient.g.cs @@ -33,6 +33,11 @@ public partial interface IJwtSettingsClient : global::System.IDisposable ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ILabelStudioClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ILabelStudioClient.g.cs index 1613038..0de0388 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ILabelStudioClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ILabelStudioClient.g.cs @@ -34,6 +34,11 @@ public partial interface ILabelStudioClient : global::System.IDisposable /// public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ILabels2Client.Create2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ILabels2Client.Create2.g.cs index bcd81f3..66f46b1 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ILabels2Client.Create2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ILabels2Client.Create2.g.cs @@ -11,6 +11,7 @@ public partial interface ILabels2Client /// /// /// + /// 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 Create2Async( @@ -18,6 +19,7 @@ public partial interface ILabels2Client global::System.Collections.Generic.IList request, string? ordering = default, int? page = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ILabels2Client.Delete2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ILabels2Client.Delete2.g.cs index 9eb9691..8059c65 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ILabels2Client.Delete2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ILabels2Client.Delete2.g.cs @@ -9,10 +9,12 @@ public partial interface ILabels2Client /// Remove labels from your project without updating the labeling configuration. /// /// + /// 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 Delete2Async( string id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ILabels2Client.Get2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ILabels2Client.Get2.g.cs index 24446c4..c1ed0af 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ILabels2Client.Get2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ILabels2Client.Get2.g.cs @@ -10,10 +10,12 @@ public partial interface ILabels2Client /// /// /// + /// 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 Get2Async( string id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ILabels2Client.List2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ILabels2Client.List2.g.cs index a822f46..c630826 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ILabels2Client.List2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ILabels2Client.List2.g.cs @@ -10,11 +10,13 @@ public partial interface ILabels2Client /// /// /// + /// 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 List2Async( string? ordering = default, int? page = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ILabels2Client.Update2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ILabels2Client.Update2.g.cs index 275d425..a1b2353 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ILabels2Client.Update2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ILabels2Client.Update2.g.cs @@ -10,12 +10,14 @@ public partial interface ILabels2Client /// /// /// + /// 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 Update2Async( string id, global::LabelStudio.PatchedLabelRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Update labels
@@ -41,6 +43,7 @@ public partial interface ILabels2Client /// /// Label value /// + /// 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 Update2Async( @@ -52,6 +55,7 @@ public partial interface ILabels2Client int? organization = default, string? title = default, object? value = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ILabels2Client.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ILabels2Client.g.cs index 879814c..7ddb4a7 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ILabels2Client.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ILabels2Client.g.cs @@ -33,6 +33,11 @@ public partial interface ILabels2Client : global::System.IDisposable ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ILabelsClient.Create.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ILabelsClient.Create.g.cs index 4b69214..924430e 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ILabelsClient.Create.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ILabelsClient.Create.g.cs @@ -9,11 +9,13 @@ public partial interface ILabelsClient /// Create label links to link new custom labels to your project labeling configuration. /// /// + /// 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 CreateAsync( global::LabelStudio.LabelLinkRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Create label links
@@ -24,12 +26,14 @@ public partial interface ILabelsClient /// /// /// + /// 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 CreateAsync( string fromName, int label, int project, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ILabelsClient.Delete.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ILabelsClient.Delete.g.cs index 4822eab..42e05ba 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ILabelsClient.Delete.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ILabelsClient.Delete.g.cs @@ -11,10 +11,12 @@ public partial interface ILabelsClient /// ///
/// + /// 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 DeleteAsync( string id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ILabelsClient.Get.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ILabelsClient.Get.g.cs index b2d2984..9fe16a5 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ILabelsClient.Get.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ILabelsClient.Get.g.cs @@ -9,10 +9,12 @@ public partial interface ILabelsClient /// Get label links for a specific project configuration. /// /// + /// 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 GetAsync( string id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ILabelsClient.List.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ILabelsClient.List.g.cs index e222649..4a694f9 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ILabelsClient.List.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ILabelsClient.List.g.cs @@ -9,10 +9,12 @@ public partial interface ILabelsClient /// List label links for a specific label and project. /// /// + /// 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 ListAsync( int? page = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ILabelsClient.Update.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ILabelsClient.Update.g.cs index 866640a..1b63384 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ILabelsClient.Update.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ILabelsClient.Update.g.cs @@ -12,12 +12,14 @@ public partial interface ILabelsClient /// /// /// + /// 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 UpdateAsync( string id, global::LabelStudio.PatchedLabelLinkRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Update label link
@@ -31,6 +33,7 @@ public partial interface ILabelsClient /// /// /// + /// 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 UpdateAsync( @@ -38,6 +41,7 @@ public partial interface ILabelsClient string? fromName = default, int? label = default, int? project = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ILabelsClient.UpdateMany.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ILabelsClient.UpdateMany.g.cs index 62fb6f6..2c5e310 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ILabelsClient.UpdateMany.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ILabelsClient.UpdateMany.g.cs @@ -9,9 +9,11 @@ public partial interface ILabelsClient /// If you want to update the labels in saved annotations, use this endpoint.
/// ///
+ /// 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 UpdateManyAsync( + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ILabelsClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ILabelsClient.g.cs index 3b0775a..a28fd31 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ILabelsClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ILabelsClient.g.cs @@ -33,6 +33,11 @@ public partial interface ILabelsClient : global::System.IDisposable /// public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ILlmClient.ApiLlmOpenaiChatCompletionsCreate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ILlmClient.ApiLlmOpenaiChatCompletionsCreate.g.cs index 4429267..d224b51 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ILlmClient.ApiLlmOpenaiChatCompletionsCreate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ILlmClient.ApiLlmOpenaiChatCompletionsCreate.g.cs @@ -9,11 +9,13 @@ public partial interface ILlmClient /// Proxy requests to OpenAI-compatible chat completions APIs and return the full response payload. Supports multiple providers via model parameter format: "model_name" (defaults to OpenAI), "provider/model_name", or "provider:model_name". Works with providers that offer OpenAI-compatible endpoints. /// /// + /// 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 ApiLlmOpenaiChatCompletionsCreateAsync( global::LabelStudio.ApiLlmOpenaiChatCompletionsCreateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Proxy to OpenAI-Compatible Chat Completions
@@ -26,11 +28,13 @@ public partial interface ILlmClient /// Model identifier. Can be "model_name" (defaults to OpenAI), "provider/model_name", or "provider:model_name"
/// Example: gpt-4 /// + /// 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 ApiLlmOpenaiChatCompletionsCreateAsync( global::System.Collections.Generic.IList messages, string model, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ILlmClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ILlmClient.g.cs index 9462811..35b3811 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ILlmClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ILlmClient.g.cs @@ -33,6 +33,11 @@ public partial interface ILlmClient : global::System.IDisposable ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IMlClient.Create.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IMlClient.Create.g.cs index 93f8603..3915779 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IMlClient.Create.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IMlClient.Create.g.cs @@ -14,11 +14,13 @@ public partial interface IMlClient /// /// /// + /// 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 CreateAsync( global::LabelStudio.ApiMlCreateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Add ML Backend
@@ -59,6 +61,7 @@ public partial interface IMlClient /// /// ML backend URL /// + /// 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 CreateAsync( @@ -72,6 +75,7 @@ public partial interface IMlClient int? timeout = default, string? title = default, string? url = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IMlClient.Delete.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IMlClient.Delete.g.cs index 722c04f..9047988 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IMlClient.Delete.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IMlClient.Delete.g.cs @@ -13,10 +13,12 @@ public partial interface IMlClient /// ///
/// + /// 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 DeleteAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IMlClient.Get.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IMlClient.Get.g.cs index fd2ee54..9e36ecd 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IMlClient.Get.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IMlClient.Get.g.cs @@ -13,10 +13,12 @@ public partial interface IMlClient /// /// /// + /// 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 GetAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IMlClient.List.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IMlClient.List.g.cs index 24323b4..7a7360e 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IMlClient.List.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IMlClient.List.g.cs @@ -13,10 +13,12 @@ public partial interface IMlClient /// /// /// + /// 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> ListAsync( int? project = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IMlClient.ListModelVersions.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IMlClient.ListModelVersions.g.cs index 2e2a42b..742f832 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IMlClient.ListModelVersions.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IMlClient.ListModelVersions.g.cs @@ -9,10 +9,12 @@ public partial interface IMlClient /// Get available versions of the model. /// /// + /// 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 ListModelVersionsAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IMlClient.PredictAllTasks.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IMlClient.PredictAllTasks.g.cs index 18e87a8..b48f153 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IMlClient.PredictAllTasks.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IMlClient.PredictAllTasks.g.cs @@ -18,11 +18,13 @@ public partial interface IMlClient /// /// /// + /// 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 PredictAllTasksAsync( int id, int? batchSize = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IMlClient.PredictInteractive.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IMlClient.PredictInteractive.g.cs index 5f2b9a0..15e7e8b 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IMlClient.PredictInteractive.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IMlClient.PredictInteractive.g.cs @@ -13,12 +13,14 @@ public partial interface IMlClient /// /// /// + /// 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 PredictInteractiveAsync( int id, global::LabelStudio.MLInteractiveAnnotatingRequestRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Request Interactive Annotation
@@ -34,12 +36,14 @@ public partial interface IMlClient /// /// ID of task to annotate /// + /// 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 PredictInteractiveAsync( int id, int task, object? context = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IMlClient.TestPredict.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IMlClient.TestPredict.g.cs index 522323f..7a876c3 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IMlClient.TestPredict.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IMlClient.TestPredict.g.cs @@ -11,12 +11,14 @@ public partial interface IMlClient ///
/// /// + /// 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 TestPredictAsync( int id, global::LabelStudio.MLBackendRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Test prediction
@@ -69,6 +71,7 @@ public partial interface IMlClient /// /// URL for the machine learning model server /// + /// 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 TestPredictAsync( @@ -87,6 +90,7 @@ public partial interface IMlClient global::LabelStudio.StateEnum? state = default, double? timeout = default, string? title = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IMlClient.Train.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IMlClient.Train.g.cs index 49e59ff..0926242 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IMlClient.Train.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IMlClient.Train.g.cs @@ -14,12 +14,14 @@ public partial interface IMlClient ///
/// /// + /// 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 TrainAsync( int id, global::LabelStudio.ApiMlTrainCreateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Train
@@ -33,11 +35,13 @@ public partial interface IMlClient /// /// Whether to include ground truth annotations in training /// + /// 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 TrainAsync( int id, bool? useGroundTruth = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IMlClient.Update.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IMlClient.Update.g.cs index 012e39b..decc81c 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IMlClient.Update.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IMlClient.Update.g.cs @@ -14,12 +14,14 @@ public partial interface IMlClient ///
/// /// + /// 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 UpdateAsync( int id, global::LabelStudio.ApiMlPartialUpdateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Update ML Backend
@@ -60,6 +62,7 @@ public partial interface IMlClient /// /// ML backend URL /// + /// 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 UpdateAsync( @@ -74,6 +77,7 @@ public partial interface IMlClient int? timeout = default, string? title = default, string? url = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IMlClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IMlClient.g.cs index 98dddac..29c0c74 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IMlClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IMlClient.g.cs @@ -33,6 +33,11 @@ public partial interface IMlClient : global::System.IDisposable ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IModelProviderConnectionClient.ApiModelProviderConnectionsUpdate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IModelProviderConnectionClient.ApiModelProviderConnectionsUpdate.g.cs index a37ca2b..c099b02 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IModelProviderConnectionClient.ApiModelProviderConnectionsUpdate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IModelProviderConnectionClient.ApiModelProviderConnectionsUpdate.g.cs @@ -16,12 +16,14 @@ public partial interface IModelProviderConnectionClient /// /// /// + /// 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 ApiModelProviderConnectionsUpdateAsync( string id, global::LabelStudio.ModelProviderConnectionRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Put model provider connection
@@ -81,6 +83,7 @@ public partial interface IModelProviderConnectionClient /// * `User` - User
/// * `Model` - Model /// + /// 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 ApiModelProviderConnectionsUpdateAsync( @@ -97,6 +100,7 @@ public partial interface IModelProviderConnectionClient bool? isInternal = default, global::LabelStudio.ProviderEnum? provider = default, global::LabelStudio.ScopeEnum? scope = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IModelProviderConnectionClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IModelProviderConnectionClient.g.cs index be68b3c..afb3a07 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IModelProviderConnectionClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IModelProviderConnectionClient.g.cs @@ -33,6 +33,11 @@ public partial interface IModelProviderConnectionClient : global::System.IDispos ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IModelProvidersClient.Create.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IModelProvidersClient.Create.g.cs index 10d4771..928f00f 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IModelProvidersClient.Create.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IModelProvidersClient.Create.g.cs @@ -15,11 +15,13 @@ public partial interface IModelProvidersClient /// Create a new model provider connection. /// /// + /// 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 CreateAsync( global::LabelStudio.ModelProviderConnectionRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Create model provider connection
@@ -78,6 +80,7 @@ public partial interface IModelProvidersClient /// * `User` - User
/// * `Model` - Model /// + /// 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 CreateAsync( @@ -93,6 +96,7 @@ public partial interface IModelProvidersClient bool? isInternal = default, global::LabelStudio.ProviderEnum? provider = default, global::LabelStudio.ScopeEnum? scope = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IModelProvidersClient.Delete.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IModelProvidersClient.Delete.g.cs index e85bcbf..c29d719 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IModelProvidersClient.Delete.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IModelProvidersClient.Delete.g.cs @@ -15,10 +15,12 @@ public partial interface IModelProvidersClient /// Delete a model provider connection by ID ///
/// + /// 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 DeleteAsync( string id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IModelProvidersClient.Get.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IModelProvidersClient.Get.g.cs index 756bafc..981a89b 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IModelProvidersClient.Get.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IModelProvidersClient.Get.g.cs @@ -15,10 +15,12 @@ public partial interface IModelProvidersClient /// Retrieve a specific model provider connection. /// /// + /// 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 GetAsync( string id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IModelProvidersClient.List.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IModelProvidersClient.List.g.cs index 331deb2..3cb3695 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IModelProvidersClient.List.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IModelProvidersClient.List.g.cs @@ -15,10 +15,12 @@ public partial interface IModelProvidersClient /// List all model provider connections. /// /// + /// 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> ListAsync( string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IModelProvidersClient.ListModelProviderChoices.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IModelProvidersClient.ListModelProviderChoices.g.cs index 5540c8d..53dc688 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IModelProvidersClient.ListModelProviderChoices.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IModelProvidersClient.ListModelProviderChoices.g.cs @@ -14,9 +14,11 @@ public partial interface IModelProvidersClient /// </Card>
/// List all possible model provider choices /// + /// 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 ListModelProviderChoicesAsync( + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IModelProvidersClient.Update.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IModelProvidersClient.Update.g.cs index e929c27..fea02fa 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IModelProvidersClient.Update.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IModelProvidersClient.Update.g.cs @@ -16,12 +16,14 @@ public partial interface IModelProvidersClient /// /// /// + /// 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 UpdateAsync( string id, global::LabelStudio.PatchedModelProviderConnectionRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Update model provider connection
@@ -81,6 +83,7 @@ public partial interface IModelProvidersClient /// * `User` - User
/// * `Model` - Model /// + /// 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 UpdateAsync( @@ -97,6 +100,7 @@ public partial interface IModelProvidersClient bool? isInternal = default, global::LabelStudio.ProviderEnum? provider = default, global::LabelStudio.ScopeEnum? scope = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IModelProvidersClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IModelProvidersClient.g.cs index 4a1cd00..6df1542 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IModelProvidersClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IModelProvidersClient.g.cs @@ -33,6 +33,11 @@ public partial interface IModelProvidersClient : global::System.IDisposable ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IOrganizations2Client.Get.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IOrganizations2Client.Get.g.cs index 40dac78..ba21118 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IOrganizations2Client.Get.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IOrganizations2Client.Get.g.cs @@ -9,10 +9,12 @@ public partial interface IOrganizations2Client /// Retrieve the settings for a specific organization by ID. /// /// + /// 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 GetAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IOrganizations2Client.List.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IOrganizations2Client.List.g.cs index 3375f2a..f1d836a 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IOrganizations2Client.List.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IOrganizations2Client.List.g.cs @@ -10,10 +10,12 @@ public partial interface IOrganizations2Client /// /// /// + /// 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> ListAsync( string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IOrganizations2Client.ResetToken.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IOrganizations2Client.ResetToken.g.cs index 772bb7d..2453ff2 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IOrganizations2Client.ResetToken.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IOrganizations2Client.ResetToken.g.cs @@ -8,9 +8,11 @@ public partial interface IOrganizations2Client /// Reset organization token
/// Reset the token used in the invitation link to invite someone to an 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 ResetTokenAsync( + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IOrganizations2Client.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IOrganizations2Client.g.cs index 3b14bf6..57f8c99 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IOrganizations2Client.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IOrganizations2Client.g.cs @@ -33,6 +33,11 @@ public partial interface IOrganizations2Client : global::System.IDisposable /// public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.Assign.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.Assign.g.cs index 345077a..1412181 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.Assign.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.Assign.g.cs @@ -23,6 +23,7 @@ public partial interface IOrganizationsClient /// /// /// + /// 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 AssignAsync( @@ -36,6 +37,7 @@ public partial interface IOrganizationsClient string? tags = default, string? userLastActivityGte = default, string? userLastActivityLte = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Bulk assign tags to organization members
@@ -71,6 +73,7 @@ public partial interface IOrganizationsClient /// /// List of tag IDs to assign. /// + /// 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 AssignAsync( @@ -87,6 +90,7 @@ public partial interface IOrganizationsClient global::System.Collections.Generic.IList? included = default, bool? overwrite = default, global::System.Collections.Generic.IList? requestTags = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.Create.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.Create.g.cs index 78257e4..366428c 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.Create.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.Create.g.cs @@ -16,12 +16,14 @@ public partial interface IOrganizationsClient ///
/// /// + /// 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 CreateAsync( int id, global::LabelStudio.OrganizationMemberTagRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Create organization member tag
@@ -37,11 +39,13 @@ public partial interface IOrganizationsClient /// /// Label /// + /// 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 CreateAsync( int id, string label, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.Create2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.Create2.g.cs index 3c5f7e7..77e0c21 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.Create2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.Create2.g.cs @@ -16,12 +16,14 @@ public partial interface IOrganizationsClient ///
/// /// + /// 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 Create2Async( int id, global::LabelStudio.OrganizationPermissionRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Create organization permission override
@@ -38,12 +40,14 @@ public partial interface IOrganizationsClient /// /// Organization roles /// + /// 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 Create2Async( int id, string permission, global::System.Collections.Generic.IList? roles = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.Delete.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.Delete.g.cs index 0808aef..df7ec54 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.Delete.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.Delete.g.cs @@ -16,11 +16,13 @@ public partial interface IOrganizationsClient ///
/// /// + /// 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 DeleteAsync( int id, string? ids = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.Delete2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.Delete2.g.cs index 004999f..12d2c16 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.Delete2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.Delete2.g.cs @@ -16,11 +16,13 @@ public partial interface IOrganizationsClient /// /// /// + /// 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 Delete2Async( int id, int tagPk, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.Delete3.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.Delete3.g.cs index 5f4e079..e13e4dd 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.Delete3.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.Delete3.g.cs @@ -10,11 +10,13 @@ public partial interface IOrganizationsClient /// /// /// + /// 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 Delete3Async( int id, int userPk, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.Delete4.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.Delete4.g.cs index f03e67e..f0f7b4f 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.Delete4.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.Delete4.g.cs @@ -16,11 +16,13 @@ public partial interface IOrganizationsClient /// /// /// + /// 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 Delete4Async( int id, string permission, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.Get2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.Get2.g.cs index c43fe6e..514b842 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.Get2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.Get2.g.cs @@ -16,11 +16,13 @@ public partial interface IOrganizationsClient /// /// /// + /// 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 Get2Async( int id, int tagPk, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.Get3.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.Get3.g.cs index 713f46d..5448e9f 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.Get3.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.Get3.g.cs @@ -11,12 +11,14 @@ public partial interface IOrganizationsClient /// /// /// + /// 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 Get3Async( int id, int userPk, bool? contributedToProjects = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.Get4.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.Get4.g.cs index 9fc526e..e343437 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.Get4.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.Get4.g.cs @@ -16,11 +16,13 @@ public partial interface IOrganizationsClient /// /// /// + /// 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 Get4Async( int id, string permission, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.GetImport.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.GetImport.g.cs index be9c6e4..88613a1 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.GetImport.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.GetImport.g.cs @@ -17,11 +17,13 @@ public partial interface IOrganizationsClient /// /// /// + /// 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 GetImportAsync( int id, int importPk, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.GetInviteLink.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.GetInviteLink.g.cs index 09b71d9..6a0e894 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.GetInviteLink.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.GetInviteLink.g.cs @@ -8,9 +8,11 @@ public partial interface IOrganizationsClient /// Get invite link
/// Get invite link for 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 GetInviteLinkAsync( + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.GetOptions.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.GetOptions.g.cs index bcb384a..7fee92f 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.GetOptions.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.GetOptions.g.cs @@ -16,11 +16,13 @@ public partial interface IOrganizationsClient /// /// /// + /// 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> GetOptionsAsync( int id, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.Import.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.Import.g.cs index 34e0bad..ba6aa7e 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.Import.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.Import.g.cs @@ -19,12 +19,14 @@ public partial interface IOrganizationsClient /// /// /// + /// 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 ImportAsync( int id, global::LabelStudio.OrganizationMemberTagImportCreateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Import member tags from CSV
@@ -43,6 +45,7 @@ public partial interface IOrganizationsClient /// /// /// + /// 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 ImportAsync( @@ -50,6 +53,7 @@ public partial interface IOrganizationsClient string bulkTags, byte[] file, string filename, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.List2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.List2.g.cs index bad723d..e45221c 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.List2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.List2.g.cs @@ -19,6 +19,7 @@ public partial interface IOrganizationsClient /// /// /// + /// 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 List2Async( @@ -27,6 +28,7 @@ public partial interface IOrganizationsClient int? page = default, int? pageSize = default, string? search = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.List3.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.List3.g.cs index 268321f..414b576 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.List3.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.List3.g.cs @@ -25,6 +25,7 @@ public partial interface IOrganizationsClient /// /// /// + /// 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 List3Async( @@ -39,6 +40,7 @@ public partial interface IOrganizationsClient global::LabelStudio.ApiOrganizationsMembershipsListScope? scope = default, string? search = default, string? tags = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.List4.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.List4.g.cs index dafb7a0..34b6455 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.List4.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.List4.g.cs @@ -16,11 +16,13 @@ public partial interface IOrganizationsClient ///
/// /// + /// 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> List4Async( int id, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.Post.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.Post.g.cs index 0babd32..31007f3 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.Post.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.Post.g.cs @@ -16,12 +16,14 @@ public partial interface IOrganizationsClient /// /// /// + /// 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 PostAsync( int id, global::LabelStudio.OrganizationMemberTagBulkCreateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Bulk create organization member tags
@@ -37,11 +39,13 @@ public partial interface IOrganizationsClient /// /// List of tag labels to create. /// + /// 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 PostAsync( int id, global::System.Collections.Generic.IList labels, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.Replace.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.Replace.g.cs index 04e2b20..2527c9b 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.Replace.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.Replace.g.cs @@ -17,6 +17,7 @@ public partial interface IOrganizationsClient /// /// /// + /// 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 ReplaceAsync( @@ -24,6 +25,7 @@ public partial interface IOrganizationsClient string permission, global::LabelStudio.OrganizationPermissionRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Replace organization permission override
@@ -41,6 +43,7 @@ public partial interface IOrganizationsClient /// /// Organization roles /// + /// 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 ReplaceAsync( @@ -48,6 +51,7 @@ public partial interface IOrganizationsClient string permission, string requestPermission, global::System.Collections.Generic.IList? roles = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.RevokeInvite.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.RevokeInvite.g.cs index fe3d5af..7bfdffb 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.RevokeInvite.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.RevokeInvite.g.cs @@ -15,11 +15,13 @@ public partial interface IOrganizationsClient /// Revoke invite to 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 RevokeInviteAsync( global::LabelStudio.RevokeInviteRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Revoke invite
@@ -34,10 +36,12 @@ public partial interface IOrganizationsClient /// /// Email address /// + /// 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 RevokeInviteAsync( string email, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.SendEmail.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.SendEmail.g.cs index 4f3fb80..63d3d1d 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.SendEmail.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.SendEmail.g.cs @@ -15,11 +15,13 @@ public partial interface IOrganizationsClient /// Send email with invite to 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 SendEmailAsync( global::LabelStudio.SendInviteRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Send email with invite
@@ -50,6 +52,7 @@ public partial interface IOrganizationsClient /// /// Workspace IDs to grant access to /// + /// 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 SendEmailAsync( @@ -57,6 +60,7 @@ public partial interface IOrganizationsClient global::LabelStudio.Role9e7Enum role, global::System.Collections.Generic.IList? projects = default, global::System.Collections.Generic.IList? workspaces = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.Update.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.Update.g.cs index 7653d4c..46e5d65 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.Update.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.Update.g.cs @@ -16,12 +16,14 @@ public partial interface IOrganizationsClient ///
/// /// + /// 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 UpdateAsync( int id, global::LabelStudio.PatchedLseOrganizationSerializerUpdateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Update organization
@@ -61,6 +63,7 @@ public partial interface IOrganizationsClient /// Included only in requests /// /// + /// 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 UpdateAsync( @@ -74,6 +77,7 @@ public partial interface IOrganizationsClient string? contactInfo = default, int? createdBy = default, string? token = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.Update2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.Update2.g.cs index 6a37227..05598ff 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.Update2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.Update2.g.cs @@ -17,6 +17,7 @@ public partial interface IOrganizationsClient /// /// /// + /// 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 Update2Async( @@ -24,6 +25,7 @@ public partial interface IOrganizationsClient int tagPk, global::LabelStudio.PatchedOrganizationMemberTagRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Update organization member tag
@@ -40,12 +42,14 @@ public partial interface IOrganizationsClient /// /// Label /// + /// 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 Update2Async( int id, int tagPk, string? label = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.Update3.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.Update3.g.cs index e83cf15..3ebdf8b 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.Update3.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.Update3.g.cs @@ -22,12 +22,14 @@ public partial interface IOrganizationsClient ///
/// /// + /// 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 Update3Async( int id, global::LabelStudio.PatchedOrganizationMemberCreateUpdateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Update organization member/role
@@ -59,12 +61,14 @@ public partial interface IOrganizationsClient /// /// Member /// + /// 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 Update3Async( int id, global::LabelStudio.Role9e7Enum? role = default, int? userId = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.Update4.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.Update4.g.cs index 7057715..8b88256 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.Update4.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.Update4.g.cs @@ -17,6 +17,7 @@ public partial interface IOrganizationsClient /// /// /// + /// 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 Update4Async( @@ -24,6 +25,7 @@ public partial interface IOrganizationsClient string permission, global::LabelStudio.PatchedOrganizationPermissionRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Update organization permission override
@@ -41,6 +43,7 @@ public partial interface IOrganizationsClient /// /// Organization roles /// + /// 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 Update4Async( @@ -48,6 +51,7 @@ public partial interface IOrganizationsClient string permission, string? requestPermission = default, global::System.Collections.Generic.IList? roles = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.UpdateDefaultRole.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.UpdateDefaultRole.g.cs index 6746f79..ba917ad 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.UpdateDefaultRole.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.UpdateDefaultRole.g.cs @@ -16,12 +16,14 @@ public partial interface IOrganizationsClient ///
/// /// + /// 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 UpdateDefaultRoleAsync( int id, global::LabelStudio.PatchedDefaultRoleRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Update default role
@@ -75,6 +77,7 @@ public partial interface IOrganizationsClient /// /// Set to current time to prevent creating or editing annotations in quick view. /// + /// 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 UpdateDefaultRoleAsync( @@ -91,6 +94,7 @@ public partial interface IOrganizationsClient int? organization = default, object? reactCodeSettings = default, global::System.DateTime? readOnlyQuickViewEnabledAt = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.g.cs index ccf3dbb..1458a2e 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IOrganizationsClient.g.cs @@ -33,6 +33,11 @@ public partial interface IOrganizationsClient : global::System.IDisposable ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IPausesClient.ApiProjectsMembersPausesUpdate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IPausesClient.ApiProjectsMembersPausesUpdate.g.cs index d9b18c9..b4a6218 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IPausesClient.ApiProjectsMembersPausesUpdate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IPausesClient.ApiProjectsMembersPausesUpdate.g.cs @@ -18,6 +18,7 @@ public partial interface IPausesClient /// /// /// + /// 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 ApiProjectsMembersPausesUpdateAsync( @@ -26,6 +27,7 @@ public partial interface IPausesClient int userPk, global::LabelStudio.PauseRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Put pause
@@ -51,6 +53,7 @@ public partial interface IPausesClient /// /// Detailed description of why the project is paused, will be readable by paused annotators /// + /// 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 ApiProjectsMembersPausesUpdateAsync( @@ -59,6 +62,7 @@ public partial interface IPausesClient int userPk, global::LabelStudio.ReasonEnum reason, string? verboseReason = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IPausesClient.Create.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IPausesClient.Create.g.cs index d5fd85a..4898500 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IPausesClient.Create.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IPausesClient.Create.g.cs @@ -17,6 +17,7 @@ public partial interface IPausesClient /// /// /// + /// 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 CreateAsync( @@ -24,6 +25,7 @@ public partial interface IPausesClient int userPk, global::LabelStudio.PauseRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Create pause
@@ -48,6 +50,7 @@ public partial interface IPausesClient /// /// Detailed description of why the project is paused, will be readable by paused annotators /// + /// 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 CreateAsync( @@ -55,6 +58,7 @@ public partial interface IPausesClient int userPk, global::LabelStudio.ReasonEnum reason, string? verboseReason = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IPausesClient.Delete.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IPausesClient.Delete.g.cs index 6a23cf4..6e85a02 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IPausesClient.Delete.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IPausesClient.Delete.g.cs @@ -17,12 +17,14 @@ public partial interface IPausesClient /// /// /// + /// 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 DeleteAsync( string id, int projectPk, int userPk, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IPausesClient.Get.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IPausesClient.Get.g.cs index cf3414b..f63c04a 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IPausesClient.Get.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IPausesClient.Get.g.cs @@ -17,12 +17,14 @@ public partial interface IPausesClient /// /// /// + /// 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 GetAsync( string id, int projectPk, int userPk, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IPausesClient.List.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IPausesClient.List.g.cs index c6ef5a2..7cf96d1 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IPausesClient.List.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IPausesClient.List.g.cs @@ -18,6 +18,7 @@ public partial interface IPausesClient /// /// /// + /// 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> ListAsync( @@ -25,6 +26,7 @@ public partial interface IPausesClient int userPk, bool? includeDeleted = default, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IPausesClient.Update.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IPausesClient.Update.g.cs index 0fc3f5e..1874cd0 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IPausesClient.Update.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IPausesClient.Update.g.cs @@ -18,6 +18,7 @@ public partial interface IPausesClient /// /// /// + /// 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 UpdateAsync( @@ -26,6 +27,7 @@ public partial interface IPausesClient int userPk, global::LabelStudio.PatchedPauseRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Update pause
@@ -51,6 +53,7 @@ public partial interface IPausesClient /// /// Detailed description of why the project is paused, will be readable by paused annotators /// + /// 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 UpdateAsync( @@ -59,6 +62,7 @@ public partial interface IPausesClient int userPk, global::LabelStudio.ReasonEnum? reason = default, string? verboseReason = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IPausesClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IPausesClient.g.cs index b836e89..4410195 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IPausesClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IPausesClient.g.cs @@ -33,6 +33,11 @@ public partial interface IPausesClient : global::System.IDisposable ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IPredictions2Client.Create.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IPredictions2Client.Create.g.cs index a655542..e7e97ef 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IPredictions2Client.Create.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IPredictions2Client.Create.g.cs @@ -9,11 +9,13 @@ public partial interface IPredictions2Client /// Create a prediction for a specific task. ///
/// + /// 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 CreateAsync( global::LabelStudio.ApiPredictionsCreateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Create prediction
@@ -34,6 +36,7 @@ public partial interface IPredictions2Client /// /// Task ID for which the prediction is created /// + /// 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 CreateAsync( @@ -41,6 +44,7 @@ public partial interface IPredictions2Client global::System.Collections.Generic.IList? result = default, double? score = default, int? task = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IPredictions2Client.Delete.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IPredictions2Client.Delete.g.cs index f3cff89..853f992 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IPredictions2Client.Delete.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IPredictions2Client.Delete.g.cs @@ -9,10 +9,12 @@ public partial interface IPredictions2Client /// Delete a prediction by prediction ID. /// /// + /// 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 DeleteAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IPredictions2Client.Get.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IPredictions2Client.Get.g.cs index 5b30c1e..1ae50a9 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IPredictions2Client.Get.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IPredictions2Client.Get.g.cs @@ -9,10 +9,12 @@ public partial interface IPredictions2Client /// Get details about a specific prediction by its ID. /// /// + /// 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 GetAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IPredictions2Client.List.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IPredictions2Client.List.g.cs index 5915e8b..d0e3164 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IPredictions2Client.List.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IPredictions2Client.List.g.cs @@ -10,11 +10,13 @@ public partial interface IPredictions2Client /// /// /// + /// 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> ListAsync( int? project = default, int? task = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IPredictions2Client.Update.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IPredictions2Client.Update.g.cs index d343c50..173b648 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IPredictions2Client.Update.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IPredictions2Client.Update.g.cs @@ -10,12 +10,14 @@ public partial interface IPredictions2Client /// /// /// + /// 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 UpdateAsync( int id, global::LabelStudio.ApiPredictionsPartialUpdateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Update prediction
@@ -37,6 +39,7 @@ public partial interface IPredictions2Client /// /// Task ID for which the prediction is created /// + /// 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 UpdateAsync( @@ -45,6 +48,7 @@ public partial interface IPredictions2Client global::System.Collections.Generic.IList? result = default, double? score = default, int? task = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IPredictions2Client.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IPredictions2Client.g.cs index 0709f94..33b071c 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IPredictions2Client.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IPredictions2Client.g.cs @@ -33,6 +33,11 @@ public partial interface IPredictions2Client : global::System.IDisposable /// public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IPredictionsClient.ApiPredictionsUpdate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IPredictionsClient.ApiPredictionsUpdate.g.cs index a2a26a5..e2b2f3a 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IPredictionsClient.ApiPredictionsUpdate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IPredictionsClient.ApiPredictionsUpdate.g.cs @@ -10,12 +10,14 @@ public partial interface IPredictionsClient /// /// /// + /// 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 ApiPredictionsUpdateAsync( int id, global::LabelStudio.ApiPredictionsUpdateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Put prediction
@@ -37,6 +39,7 @@ public partial interface IPredictionsClient /// /// Task ID for which the prediction is created /// + /// 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 ApiPredictionsUpdateAsync( @@ -45,6 +48,7 @@ public partial interface IPredictionsClient global::System.Collections.Generic.IList? result = default, double? score = default, int? task = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IPredictionsClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IPredictionsClient.g.cs index e4a0367..fb1a2d7 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IPredictionsClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IPredictionsClient.g.cs @@ -33,6 +33,11 @@ public partial interface IPredictionsClient : global::System.IDisposable /// public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IProjectRolesClient.Add.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IProjectRolesClient.Add.g.cs index 8cd4af5..6d89810 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IProjectRolesClient.Add.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IProjectRolesClient.Add.g.cs @@ -16,11 +16,13 @@ public partial interface IProjectRolesClient /// /// /// + /// 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 AddAsync( global::LabelStudio.ProjectRoleRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Create project role for user
@@ -44,12 +46,14 @@ public partial interface IProjectRolesClient /// * `NO` - Not Activated /// /// + /// 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 AddAsync( int project, global::LabelStudio.Role9e7Enum role, int user, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IProjectRolesClient.Get.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IProjectRolesClient.Get.g.cs index 0b5b6db..f57dd67 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IProjectRolesClient.Get.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IProjectRolesClient.Get.g.cs @@ -17,10 +17,12 @@ public partial interface IProjectRolesClient /// ///
/// + /// 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> GetAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IProjectRolesClient.List.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IProjectRolesClient.List.g.cs index 5dbbfea..79fcd20 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IProjectRolesClient.List.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IProjectRolesClient.List.g.cs @@ -17,11 +17,13 @@ public partial interface IProjectRolesClient /// /// /// + /// 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> ListAsync( int? ids = default, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IProjectRolesClient.Remove.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IProjectRolesClient.Remove.g.cs index 9b471e5..54bd439 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IProjectRolesClient.Remove.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IProjectRolesClient.Remove.g.cs @@ -16,10 +16,12 @@ public partial interface IProjectRolesClient /// /// /// + /// 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 RemoveAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IProjectRolesClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IProjectRolesClient.g.cs index d117b75..d28ccab 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IProjectRolesClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IProjectRolesClient.g.cs @@ -33,6 +33,11 @@ public partial interface IProjectRolesClient : global::System.IDisposable /// public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IProjectTemplatesClient.ApiProjectTemplatesUpdate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IProjectTemplatesClient.ApiProjectTemplatesUpdate.g.cs index 6896780..bbc1dec 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IProjectTemplatesClient.ApiProjectTemplatesUpdate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IProjectTemplatesClient.ApiProjectTemplatesUpdate.g.cs @@ -16,12 +16,14 @@ public partial interface IProjectTemplatesClient /// /// /// + /// 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 ApiProjectTemplatesUpdateAsync( int id, global::LabelStudio.ProjectTemplateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Overwrite a project template
@@ -58,6 +60,7 @@ public partial interface IProjectTemplatesClient /// /// /// + /// 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 ApiProjectTemplatesUpdateAsync( @@ -74,6 +77,7 @@ public partial interface IProjectTemplatesClient object? reviewSettings = default, bool? showUnusedDataColumnsToAnnotators = default, object? tags = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IProjectTemplatesClient.Create.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IProjectTemplatesClient.Create.g.cs index fa9b4c8..90a9be6 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IProjectTemplatesClient.Create.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IProjectTemplatesClient.Create.g.cs @@ -15,11 +15,13 @@ public partial interface IProjectTemplatesClient /// Create a project template for an 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 CreateAsync( global::LabelStudio.ProjectTemplateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Create project template
@@ -55,6 +57,7 @@ public partial interface IProjectTemplatesClient /// /// /// + /// 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 CreateAsync( @@ -70,6 +73,7 @@ public partial interface IProjectTemplatesClient object? reviewSettings = default, bool? showUnusedDataColumnsToAnnotators = default, object? tags = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IProjectTemplatesClient.CreateProjectFromTemplate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IProjectTemplatesClient.CreateProjectFromTemplate.g.cs index 08b7a90..e84562f 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IProjectTemplatesClient.CreateProjectFromTemplate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IProjectTemplatesClient.CreateProjectFromTemplate.g.cs @@ -16,12 +16,14 @@ public partial interface IProjectTemplatesClient ///
/// /// + /// 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 CreateProjectFromTemplateAsync( int id, global::LabelStudio.ApiProjectTemplatesCreateProjectCreateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Create project from template
@@ -43,6 +45,7 @@ public partial interface IProjectTemplatesClient /// /// A unique integer value identifying the workspace in which to create the project. /// + /// 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 CreateProjectFromTemplateAsync( @@ -50,6 +53,7 @@ public partial interface IProjectTemplatesClient string title, int workspaceId, string? description = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IProjectTemplatesClient.Delete.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IProjectTemplatesClient.Delete.g.cs index 4782034..a761f82 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IProjectTemplatesClient.Delete.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IProjectTemplatesClient.Delete.g.cs @@ -15,10 +15,12 @@ public partial interface IProjectTemplatesClient /// Delete a specific project template by ID for an 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 DeleteAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IProjectTemplatesClient.Get.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IProjectTemplatesClient.Get.g.cs index 9560ed0..8040e53 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IProjectTemplatesClient.Get.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IProjectTemplatesClient.Get.g.cs @@ -15,10 +15,12 @@ public partial interface IProjectTemplatesClient /// Get a specific project template by ID for an 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 GetAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IProjectTemplatesClient.List.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IProjectTemplatesClient.List.g.cs index d8aa36b..7e1e67f 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IProjectTemplatesClient.List.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IProjectTemplatesClient.List.g.cs @@ -15,10 +15,12 @@ public partial interface IProjectTemplatesClient /// Get a list of all project templates for an 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> ListAsync( string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IProjectTemplatesClient.Update.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IProjectTemplatesClient.Update.g.cs index 107acc1..b632689 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IProjectTemplatesClient.Update.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IProjectTemplatesClient.Update.g.cs @@ -16,12 +16,14 @@ public partial interface IProjectTemplatesClient /// /// /// + /// 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 UpdateAsync( int id, global::LabelStudio.PatchedProjectTemplateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Update a project template
@@ -58,6 +60,7 @@ public partial interface IProjectTemplatesClient /// /// /// + /// 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 UpdateAsync( @@ -74,6 +77,7 @@ public partial interface IProjectTemplatesClient object? reviewSettings = default, bool? showUnusedDataColumnsToAnnotators = default, object? tags = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IProjectTemplatesClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IProjectTemplatesClient.g.cs index 057202b..f3f0d82 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IProjectTemplatesClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IProjectTemplatesClient.g.cs @@ -33,6 +33,11 @@ public partial interface IProjectTemplatesClient : global::System.IDisposable ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IProjects2Client.Create.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IProjects2Client.Create.g.cs index 360cf71..b240336 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IProjects2Client.Create.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IProjects2Client.Create.g.cs @@ -11,11 +11,13 @@ public partial interface IProjects2Client /// Create a project for a specific 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 CreateAsync( global::LabelStudio.LseProjectCreateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Create a project
@@ -96,6 +98,7 @@ public partial interface IProjects2Client /// /// In Workspace /// + /// 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 CreateAsync( @@ -128,6 +131,7 @@ public partial interface IProjects2Client string? taskDataPassword = default, string? title = default, int? workspace = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IProjects2Client.Delete.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IProjects2Client.Delete.g.cs index 3a3f1aa..f17139e 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IProjects2Client.Delete.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IProjects2Client.Delete.g.cs @@ -9,10 +9,12 @@ public partial interface IProjects2Client /// Delete a project by specified project ID. ///
/// + /// 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 DeleteAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IProjects2Client.Duplicate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IProjects2Client.Duplicate.g.cs index e5e00ac..d08cdc7 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IProjects2Client.Duplicate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IProjects2Client.Duplicate.g.cs @@ -16,12 +16,14 @@ public partial interface IProjects2Client /// /// /// + /// 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 DuplicateAsync( int id, global::LabelStudio.ProjectDuplicateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Duplicate project
@@ -48,6 +50,7 @@ public partial interface IProjects2Client /// /// Destination Workspace /// + /// 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 DuplicateAsync( @@ -56,6 +59,7 @@ public partial interface IProjects2Client string title, int workspace, string? description = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IProjects2Client.Get.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IProjects2Client.Get.g.cs index 3f6a728..01d6fb8 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IProjects2Client.Get.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IProjects2Client.Get.g.cs @@ -12,11 +12,13 @@ public partial interface IProjects2Client /// /// Default Value: 10 /// + /// 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 GetAsync( int id, int? membersLimit = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IProjects2Client.ImportPredictions.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IProjects2Client.ImportPredictions.g.cs index 2a7e022..b4e5d06 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IProjects2Client.ImportPredictions.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IProjects2Client.ImportPredictions.g.cs @@ -10,12 +10,14 @@ public partial interface IProjects2Client ///
/// /// + /// 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 ImportPredictionsAsync( int id, global::System.Collections.Generic.IList request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IProjects2Client.ImportTasks.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IProjects2Client.ImportTasks.g.cs index 7c50bff..bcbb7af 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IProjects2Client.ImportTasks.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IProjects2Client.ImportTasks.g.cs @@ -66,6 +66,7 @@ public partial interface IProjects2Client /// 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 ImportTasksAsync( @@ -75,6 +76,7 @@ public partial interface IProjects2Client bool? commitToProject = default, global::System.Collections.Generic.IList? preannotatedFromFields = default, bool? returnTaskIds = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IProjects2Client.List.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IProjects2Client.List.g.cs index 1c7ae03..6054659 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IProjects2Client.List.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IProjects2Client.List.g.cs @@ -24,6 +24,7 @@ public partial interface IProjects2Client /// /// /// + /// 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 ListAsync( @@ -39,6 +40,7 @@ public partial interface IProjects2Client string? state = default, string? title = default, double? workspaces = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IProjects2Client.ListCounts.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IProjects2Client.ListCounts.g.cs index 2ac2600..7700a87 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IProjects2Client.ListCounts.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IProjects2Client.ListCounts.g.cs @@ -21,6 +21,7 @@ public partial interface IProjects2Client /// /// /// + /// 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 ListCountsAsync( @@ -35,6 +36,7 @@ public partial interface IProjects2Client string? state = default, string? title = default, double? workspaces = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IProjects2Client.ListUniqueAnnotators.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IProjects2Client.ListUniqueAnnotators.g.cs index ec3be69..cccc34c 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IProjects2Client.ListUniqueAnnotators.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IProjects2Client.ListUniqueAnnotators.g.cs @@ -9,10 +9,12 @@ public partial interface IProjects2Client /// Return unique users who have submitted annotations in the specified project. /// /// + /// 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> ListUniqueAnnotatorsAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IProjects2Client.Update.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IProjects2Client.Update.g.cs index 3887b11..475a6d8 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IProjects2Client.Update.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IProjects2Client.Update.g.cs @@ -15,6 +15,7 @@ public partial interface IProjects2Client /// Default Value: 10 /// /// + /// 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 UpdateAsync( @@ -22,6 +23,7 @@ public partial interface IProjects2Client global::LabelStudio.PatchedLseProjectUpdateRequest request, int? membersLimit = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Update project details
@@ -170,6 +172,7 @@ public partial interface IProjects2Client /// /// Workspace /// + /// 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 UpdateAsync( @@ -222,6 +225,7 @@ public partial interface IProjects2Client string? taskDataPassword = default, string? title = default, int? workspace = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IProjects2Client.ValidateLabelConfig.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IProjects2Client.ValidateLabelConfig.g.cs index bcd428b..ab2f17e 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IProjects2Client.ValidateLabelConfig.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IProjects2Client.ValidateLabelConfig.g.cs @@ -10,12 +10,14 @@ public partial interface IProjects2Client ///
/// /// + /// 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 ValidateLabelConfigAsync( int id, global::LabelStudio.ProjectLabelConfigRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Validate project label config
@@ -25,11 +27,13 @@ public partial interface IProjects2Client /// /// Label config in XML format. See more about it in documentation /// + /// 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 ValidateLabelConfigAsync( int id, string labelConfig, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IProjects2Client.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IProjects2Client.g.cs index ab497c2..50ab9e9 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IProjects2Client.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IProjects2Client.g.cs @@ -33,6 +33,11 @@ public partial interface IProjects2Client : global::System.IDisposable ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.Add.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.Add.g.cs index 7e02d7e..6e84322 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.Add.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.Add.g.cs @@ -16,12 +16,14 @@ public partial interface IProjectsClient /// /// /// + /// 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 AddAsync( int id, global::LabelStudio.ProjectMemberRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Add project member
@@ -35,11 +37,13 @@ public partial interface IProjectsClient ///
/// /// + /// 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 AddAsync( int id, int user, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.ApiProjectsReimportsRetrieve.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.ApiProjectsReimportsRetrieve.g.cs index 31628d8..6228c98 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.ApiProjectsReimportsRetrieve.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.ApiProjectsReimportsRetrieve.g.cs @@ -19,11 +19,13 @@ public partial interface IProjectsClient /// /// /// + /// 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 ApiProjectsReimportsRetrieveAsync( int id, int reimportPk, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.ApiProjectsTasksList.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.ApiProjectsTasksList.g.cs index 64be04c..461334e 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.ApiProjectsTasksList.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.ApiProjectsTasksList.g.cs @@ -16,6 +16,7 @@ public partial interface IProjectsClient /// /// /// + /// 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> ApiProjectsTasksListAsync( @@ -23,6 +24,7 @@ public partial interface IProjectsClient string? ordering = default, int? page = default, int? pageSize = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.ApiProjectsValidateCreate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.ApiProjectsValidateCreate.g.cs index 22b2b63..67b415c 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.ApiProjectsValidateCreate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.ApiProjectsValidateCreate.g.cs @@ -9,11 +9,13 @@ public partial interface IProjectsClient /// Validate an arbitrary labeling configuration. /// /// + /// 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 ApiProjectsValidateCreateAsync( global::LabelStudio.ProjectLabelConfigRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Validate label config
@@ -22,10 +24,12 @@ public partial interface IProjectsClient /// /// Label config in XML format. See more about it in documentation /// + /// 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 ApiProjectsValidateCreateAsync( string labelConfig, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.CheckFunction.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.CheckFunction.g.cs index 4c92992..1fe9e22 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.CheckFunction.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.CheckFunction.g.cs @@ -16,12 +16,14 @@ public partial interface IProjectsClient ///
/// /// + /// 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 CheckFunctionAsync( int id, global::LabelStudio.CheckMatchingFunctionRequestRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Check custom matching function code
@@ -35,11 +37,13 @@ public partial interface IProjectsClient ///
/// /// + /// 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 CheckFunctionAsync( int id, string code, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.Create2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.Create2.g.cs index 6a5c086..7c7d5f0 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.Create2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.Create2.g.cs @@ -16,12 +16,14 @@ public partial interface IProjectsClient /// /// /// + /// 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 Create2Async( int id, global::LabelStudio.LseProjectParamsRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Create annotator weights for statistics
@@ -40,12 +42,14 @@ public partial interface IProjectsClient /// /// If categorical variables are used in labeling (e.g. choices), Cohen's Kappa statistic is computed to measure inter-rater reliability instead of basic agreement /// + /// 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 Create2Async( int id, global::System.Collections.Generic.Dictionary? annotatorParams = default, bool? useKappa = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.Delete2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.Delete2.g.cs index 8ac1a6f..9780521 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.Delete2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.Delete2.g.cs @@ -23,6 +23,7 @@ public partial interface IProjectsClient /// /// /// + /// 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 Delete2Async( @@ -35,6 +36,7 @@ public partial interface IProjectsClient string? role = default, string? search = default, string? tags = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.DeployFunction.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.DeployFunction.g.cs index 8616cb4..e452266 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.DeployFunction.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.DeployFunction.g.cs @@ -16,12 +16,14 @@ public partial interface IProjectsClient ///
/// /// + /// 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 DeployFunctionAsync( int id, global::LabelStudio.CustomFunctionCodeRequestRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Deploy custom metric function
@@ -35,11 +37,13 @@ public partial interface IProjectsClient ///
/// /// + /// 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 DeployFunctionAsync( int id, string code, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.Get3.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.Get3.g.cs index ce259e7..ac245c3 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.Get3.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.Get3.g.cs @@ -15,10 +15,12 @@ public partial interface IProjectsClient /// Get the current metrics configuration for a project. /// /// + /// 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 Get3Async( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.Get4.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.Get4.g.cs index 181a85e..60ca3e3 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.Get4.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.Get4.g.cs @@ -15,10 +15,12 @@ public partial interface IProjectsClient /// Retrieve the annotator weights for statistics and Cohen's Kappa for a specific project. Affects dashboard-members stats, but old and unused. /// /// + /// 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 Get4Async( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.GetFunction.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.GetFunction.g.cs index c46dee3..c0f3e24 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.GetFunction.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.GetFunction.g.cs @@ -15,10 +15,12 @@ public partial interface IProjectsClient /// Get the custom metric function code for this project. The server routes to the active cloud provider (AWS Lambda or GCP Cloud Functions) based on the CUSTOM_METRIC_PROVIDER setting. /// /// + /// 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 GetFunctionAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.GetFunctionLogs.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.GetFunctionLogs.g.cs index 1ac49b3..3eccc53 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.GetFunctionLogs.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.GetFunctionLogs.g.cs @@ -20,6 +20,7 @@ public partial interface IProjectsClient /// Default Value: 100 /// /// + /// 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 GetFunctionLogsAsync( @@ -27,6 +28,7 @@ public partial interface IProjectsClient string? endDate = default, int? limit = default, string? startDate = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.GetGcpFunction.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.GetGcpFunction.g.cs index fa27b81..70ff077 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.GetGcpFunction.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.GetGcpFunction.g.cs @@ -15,10 +15,12 @@ public partial interface IProjectsClient /// Get the GCP Cloud Function code for the custom metric configured for this project. /// /// + /// 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 GetGcpFunctionAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.GetLambda.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.GetLambda.g.cs index a05699d..b0e605b 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.GetLambda.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.GetLambda.g.cs @@ -15,10 +15,12 @@ public partial interface IProjectsClient /// Get the AWS Lambda code for the custom metric configured for this project. /// /// + /// 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 GetLambdaAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.List2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.List2.g.cs index cab6d5c..96e5dca 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.List2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.List2.g.cs @@ -33,6 +33,7 @@ public partial interface IProjectsClient /// /// /// + /// 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 List2Async( @@ -49,6 +50,7 @@ public partial interface IProjectsClient string? search = default, string? tags = default, bool? withDeleted = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.Post.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.Post.g.cs index 986bf05..fd47757 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.Post.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.Post.g.cs @@ -21,6 +21,7 @@ public partial interface IProjectsClient /// /// /// + /// 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 PostAsync( @@ -32,6 +33,7 @@ public partial interface IProjectsClient string? role = default, string? search = default, string? tags = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Bulk assign project members
@@ -61,6 +63,7 @@ public partial interface IProjectsClient /// /// Member roles /// + /// 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 PostAsync( @@ -74,6 +77,7 @@ public partial interface IProjectsClient global::System.Collections.Generic.IList? excluded = default, global::System.Collections.Generic.IList? included = default, global::System.Collections.Generic.IList? roles = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.Remove.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.Remove.g.cs index 5dc6eca..74de7b0 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.Remove.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.Remove.g.cs @@ -16,11 +16,13 @@ public partial interface IProjectsClient ///
/// /// + /// 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 RemoveAsync( int id, int? user = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.Update2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.Update2.g.cs index 3cb889d..3cff97a 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.Update2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.Update2.g.cs @@ -18,12 +18,14 @@ public partial interface IProjectsClient /// /// /// + /// 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 Update2Async( int id, global::LabelStudio.MetricParamUpdateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Update project metrics configuration
@@ -42,12 +44,14 @@ public partial interface IProjectsClient /// /// Agreement metric /// + /// 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 Update2Async( int id, object? additionalParams = default, string? metricName = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.UpdateGcpFunction.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.UpdateGcpFunction.g.cs index 2c9a1d6..831796a 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.UpdateGcpFunction.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.UpdateGcpFunction.g.cs @@ -16,12 +16,14 @@ public partial interface IProjectsClient ///
/// /// + /// 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 UpdateGcpFunctionAsync( int id, global::LabelStudio.GCPCustomFunctionUpdateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Update GCP custom metric Cloud Function
@@ -43,6 +45,7 @@ public partial interface IProjectsClient /// /// The GCP region for the Cloud Function. Uses default if not provided. /// + /// 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 UpdateGcpFunctionAsync( @@ -50,6 +53,7 @@ public partial interface IProjectsClient string code, string? project = default, string? region = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.UpdateLambda.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.UpdateLambda.g.cs index 972856b..d90ee01 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.UpdateLambda.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.UpdateLambda.g.cs @@ -16,12 +16,14 @@ public partial interface IProjectsClient ///
/// /// + /// 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 UpdateLambdaAsync( int id, global::LabelStudio.AWSCustomFunctionUpdateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Update AWS custom metric Lambda
@@ -43,6 +45,7 @@ public partial interface IProjectsClient /// /// The AWS IAM role ARN for the Lambda function. Uses default if not provided. /// + /// 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 UpdateLambdaAsync( @@ -50,6 +53,7 @@ public partial interface IProjectsClient string code, string? region = default, string? role = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.g.cs index dc44466..a50b664 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.g.cs @@ -33,6 +33,11 @@ public partial interface IProjectsClient : global::System.IDisposable ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IPrompts2Client.BatchFailedPredictions.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IPrompts2Client.BatchFailedPredictions.g.cs index ef72223..48536a3 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IPrompts2Client.BatchFailedPredictions.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IPrompts2Client.BatchFailedPredictions.g.cs @@ -16,12 +16,14 @@ public partial interface IPrompts2Client /// /// /// + /// 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 BatchFailedPredictionsAsync( global::LabelStudio.BatchFailedPredictionsRequestRequest request, int? numFailedPredictions = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Create batch of failed predictions
@@ -37,6 +39,7 @@ public partial interface IPrompts2Client /// /// /// + /// 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 BatchFailedPredictionsAsync( @@ -44,6 +47,7 @@ public partial interface IPrompts2Client int modelrunId, int? numFailedPredictions = default, string? jobId = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IPrompts2Client.BatchPredictions.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IPrompts2Client.BatchPredictions.g.cs index 2c3abc0..d03ad76 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IPrompts2Client.BatchPredictions.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IPrompts2Client.BatchPredictions.g.cs @@ -16,12 +16,14 @@ public partial interface IPrompts2Client ///
/// /// + /// 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 BatchPredictionsAsync( global::LabelStudio.BatchPredictionsRequestRequest request, int? numPredictions = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Create batch predictions
@@ -37,6 +39,7 @@ public partial interface IPrompts2Client /// /// /// + /// 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 BatchPredictionsAsync( @@ -44,6 +47,7 @@ public partial interface IPrompts2Client global::System.Collections.Generic.IList results, int? numPredictions = default, string? jobId = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IPrompts2Client.CompatibleProjects.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IPrompts2Client.CompatibleProjects.g.cs index 80947d2..1cb16bb 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IPrompts2Client.CompatibleProjects.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IPrompts2Client.CompatibleProjects.g.cs @@ -14,6 +14,7 @@ public partial interface IPrompts2Client /// /// Default Value: TextClassification /// + /// 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 CompatibleProjectsAsync( @@ -21,6 +22,7 @@ public partial interface IPrompts2Client int? page = default, int? pageSize = default, global::LabelStudio.ApiPromptsCompatibleProjectsListProjectType? projectType = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IPrompts2Client.Create.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IPrompts2Client.Create.g.cs index 84faf0c..b557db4 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IPrompts2Client.Create.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IPrompts2Client.Create.g.cs @@ -15,11 +15,13 @@ public partial interface IPrompts2Client /// Create a new prompt. /// /// + /// 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 CreateAsync( global::LabelStudio.ModelInterfaceRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Create prompt
@@ -47,6 +49,7 @@ public partial interface IPrompts2Client /// /// Model name /// + /// 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 CreateAsync( @@ -58,6 +61,7 @@ public partial interface IPrompts2Client int? organization = default, object? outputClasses = default, global::LabelStudio.SkillNameEnum? skillName = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IPrompts2Client.Delete.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IPrompts2Client.Delete.g.cs index 7727217..802da95 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IPrompts2Client.Delete.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IPrompts2Client.Delete.g.cs @@ -15,10 +15,12 @@ public partial interface IPrompts2Client /// Delete a prompt by ID ///
/// + /// 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 DeleteAsync( string id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IPrompts2Client.Get2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IPrompts2Client.Get2.g.cs index 44faaa5..3c15322 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IPrompts2Client.Get2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IPrompts2Client.Get2.g.cs @@ -15,10 +15,12 @@ public partial interface IPrompts2Client /// Retrieve a specific prompt. /// /// + /// 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 Get2Async( string id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IPrompts2Client.List2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IPrompts2Client.List2.g.cs index a099c6c..889dcd8 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IPrompts2Client.List2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IPrompts2Client.List2.g.cs @@ -9,10 +9,12 @@ public partial interface IPrompts2Client /// List all prompts. /// /// + /// 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> List2Async( string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IPrompts2Client.SubsetTasks.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IPrompts2Client.SubsetTasks.g.cs index 77132d1..8e953e7 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IPrompts2Client.SubsetTasks.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IPrompts2Client.SubsetTasks.g.cs @@ -23,6 +23,7 @@ public partial interface IPrompts2Client /// /// /// + /// 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 SubsetTasksAsync( @@ -34,6 +35,7 @@ public partial interface IPrompts2Client int? pageSize = default, int? parentModel = default, string? projectSubset = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IPrompts2Client.Subsets.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IPrompts2Client.Subsets.g.cs index 1460600..05399c9 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IPrompts2Client.Subsets.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IPrompts2Client.Subsets.g.cs @@ -17,11 +17,13 @@ public partial interface IPrompts2Client /// /// /// + /// 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> SubsetsAsync( int projectPk, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IPrompts2Client.Update.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IPrompts2Client.Update.g.cs index e087588..df5c6dd 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IPrompts2Client.Update.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IPrompts2Client.Update.g.cs @@ -16,12 +16,14 @@ public partial interface IPrompts2Client /// /// /// + /// 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 UpdateAsync( string id, global::LabelStudio.PatchedModelInterfaceRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Update prompt
@@ -50,6 +52,7 @@ public partial interface IPrompts2Client /// /// Model name /// + /// 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 UpdateAsync( @@ -62,6 +65,7 @@ public partial interface IPrompts2Client object? outputClasses = default, global::LabelStudio.SkillNameEnum? skillName = default, string? title = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IPrompts2Client.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IPrompts2Client.g.cs index b17b9d3..4f0f7bb 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IPrompts2Client.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IPrompts2Client.g.cs @@ -33,6 +33,11 @@ public partial interface IPrompts2Client : global::System.IDisposable ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IPromptsClient.ApiPromptsUpdate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IPromptsClient.ApiPromptsUpdate.g.cs index 9cc59e6..25fb265 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IPromptsClient.ApiPromptsUpdate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IPromptsClient.ApiPromptsUpdate.g.cs @@ -16,12 +16,14 @@ public partial interface IPromptsClient /// /// /// + /// 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 ApiPromptsUpdateAsync( string id, global::LabelStudio.ModelInterfaceRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Put prompt
@@ -50,6 +52,7 @@ public partial interface IPromptsClient /// /// Model name /// + /// 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 ApiPromptsUpdateAsync( @@ -62,6 +65,7 @@ public partial interface IPromptsClient int? organization = default, object? outputClasses = default, global::LabelStudio.SkillNameEnum? skillName = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IPromptsClient.ApiPromptsVersionsUpdate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IPromptsClient.ApiPromptsVersionsUpdate.g.cs index 887c5f0..2147651 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IPromptsClient.ApiPromptsVersionsUpdate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IPromptsClient.ApiPromptsVersionsUpdate.g.cs @@ -17,6 +17,7 @@ public partial interface IPromptsClient /// /// /// + /// 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 ApiPromptsVersionsUpdateAsync( @@ -24,6 +25,7 @@ public partial interface IPromptsClient int versionId, global::LabelStudio.ThirdPartyModelVersionRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Put prompt version
@@ -61,6 +63,7 @@ public partial interface IPromptsClient /// /// Model name /// + /// 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 ApiPromptsVersionsUpdateAsync( @@ -73,6 +76,7 @@ public partial interface IPromptsClient int? organization = default, int? parentModel = default, global::LabelStudio.ProviderEnum? provider = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IPromptsClient.Cancel.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IPromptsClient.Cancel.g.cs index a27bfcb..dcb73a1 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IPromptsClient.Cancel.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IPromptsClient.Cancel.g.cs @@ -17,12 +17,14 @@ public partial interface IPromptsClient /// /// /// + /// 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 CancelAsync( int inferenceRunId, int promptId, int versionId, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IPromptsClient.CostEstimate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IPromptsClient.CostEstimate.g.cs index e3d024b..a105895 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IPromptsClient.CostEstimate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IPromptsClient.CostEstimate.g.cs @@ -16,11 +16,13 @@ public partial interface IPromptsClient ///
/// /// + /// 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 CostEstimateAsync( int promptId, int versionId, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IPromptsClient.Create2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IPromptsClient.Create2.g.cs index 0fbce94..5a38133 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IPromptsClient.Create2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IPromptsClient.Create2.g.cs @@ -16,12 +16,14 @@ public partial interface IPromptsClient ///
/// /// + /// 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 Create2Async( int promptId, global::LabelStudio.ThirdPartyModelVersionRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Create prompt version
@@ -58,6 +60,7 @@ public partial interface IPromptsClient /// /// Model name /// + /// 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 Create2Async( @@ -69,6 +72,7 @@ public partial interface IPromptsClient int? organization = default, int? parentModel = default, global::LabelStudio.ProviderEnum? provider = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IPromptsClient.Create3.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IPromptsClient.Create3.g.cs index 8022be1..5354b13 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IPromptsClient.Create3.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IPromptsClient.Create3.g.cs @@ -17,6 +17,7 @@ public partial interface IPromptsClient /// /// /// + /// 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 Create3Async( @@ -24,6 +25,7 @@ public partial interface IPromptsClient int versionId, global::LabelStudio.ModelRunRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Run prompt inference
@@ -56,6 +58,7 @@ public partial interface IPromptsClient /// /// /// + /// 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 Create3Async( @@ -70,6 +73,7 @@ public partial interface IPromptsClient int? totalCorrectPredictions = default, int? totalPredictions = default, int? totalTasks = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IPromptsClient.Delete2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IPromptsClient.Delete2.g.cs index 1a1e891..23c4a97 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IPromptsClient.Delete2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IPromptsClient.Delete2.g.cs @@ -16,11 +16,13 @@ public partial interface IPromptsClient ///
/// /// + /// 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 Delete2Async( int promptId, int versionId, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IPromptsClient.Get.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IPromptsClient.Get.g.cs index e4817da..faa0990 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IPromptsClient.Get.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IPromptsClient.Get.g.cs @@ -16,11 +16,13 @@ public partial interface IPromptsClient ///
/// /// + /// 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 GetAsync( int id, string indicatorKey, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IPromptsClient.Get3.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IPromptsClient.Get3.g.cs index dbabdde..e3334a2 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IPromptsClient.Get3.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IPromptsClient.Get3.g.cs @@ -16,11 +16,13 @@ public partial interface IPromptsClient /// /// /// + /// 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 Get3Async( int promptId, int versionId, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IPromptsClient.GetDefaultVersionName.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IPromptsClient.GetDefaultVersionName.g.cs index 3ddaff9..4ff3967 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IPromptsClient.GetDefaultVersionName.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IPromptsClient.GetDefaultVersionName.g.cs @@ -15,10 +15,12 @@ public partial interface IPromptsClient /// Get default prompt version name /// /// + /// 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 GetDefaultVersionNameAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IPromptsClient.GetRefinedPrompt.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IPromptsClient.GetRefinedPrompt.g.cs index acc2afb..91d63b2 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IPromptsClient.GetRefinedPrompt.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IPromptsClient.GetRefinedPrompt.g.cs @@ -17,12 +17,14 @@ public partial interface IPromptsClient /// /// /// + /// 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 GetRefinedPromptAsync( int promptId, int versionId, string? refinementJobId = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IPromptsClient.List.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IPromptsClient.List.g.cs index 3790720..4b1773e 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IPromptsClient.List.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IPromptsClient.List.g.cs @@ -15,10 +15,12 @@ public partial interface IPromptsClient /// Get key indicators for the Prompt dashboard. /// /// + /// 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> ListAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IPromptsClient.List3.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IPromptsClient.List3.g.cs index 7d5cda1..bb73c49 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IPromptsClient.List3.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IPromptsClient.List3.g.cs @@ -16,11 +16,13 @@ public partial interface IPromptsClient /// /// /// + /// 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> List3Async( int promptId, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IPromptsClient.List4.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IPromptsClient.List4.g.cs index 895a9b1..eb73fe4 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IPromptsClient.List4.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IPromptsClient.List4.g.cs @@ -20,6 +20,7 @@ public partial interface IPromptsClient /// /// /// + /// 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> List4Async( @@ -29,6 +30,7 @@ public partial interface IPromptsClient int? parentModel = default, int? project = default, global::LabelStudio.ApiPromptsVersionsInferenceRunsListProjectSubset? projectSubset = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IPromptsClient.RefinePrompt.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IPromptsClient.RefinePrompt.g.cs index efd5677..0b7bb33 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IPromptsClient.RefinePrompt.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IPromptsClient.RefinePrompt.g.cs @@ -18,6 +18,7 @@ public partial interface IPromptsClient /// /// /// + /// 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 RefinePromptAsync( @@ -26,6 +27,7 @@ public partial interface IPromptsClient global::LabelStudio.RefinePromptRequestRequest request, bool? async = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Refine a prompt version
@@ -49,6 +51,7 @@ public partial interface IPromptsClient /// /// Model Provider Connection ID to use to refine the prompt /// + /// 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 RefinePromptAsync( @@ -58,6 +61,7 @@ public partial interface IPromptsClient string teacherModelName, int teacherModelProviderConnectionId, bool? async = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IPromptsClient.Update2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IPromptsClient.Update2.g.cs index e8aba5f..c11db64 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IPromptsClient.Update2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IPromptsClient.Update2.g.cs @@ -17,6 +17,7 @@ public partial interface IPromptsClient /// /// /// + /// 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 Update2Async( @@ -24,6 +25,7 @@ public partial interface IPromptsClient int versionId, global::LabelStudio.PatchedThirdPartyModelVersionRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Update prompt version
@@ -61,6 +63,7 @@ public partial interface IPromptsClient /// /// Model name /// + /// 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 Update2Async( @@ -73,6 +76,7 @@ public partial interface IPromptsClient global::LabelStudio.ProviderEnum? provider = default, string? providerModelId = default, string? title = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IPromptsClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IPromptsClient.g.cs index cb0c699..5672ec4 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IPromptsClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IPromptsClient.g.cs @@ -33,6 +33,11 @@ public partial interface IPromptsClient : global::System.IDisposable ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ISessionPolicyClient.Get.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ISessionPolicyClient.Get.g.cs index 7a1630c..2707a98 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ISessionPolicyClient.Get.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ISessionPolicyClient.Get.g.cs @@ -8,9 +8,11 @@ public partial interface ISessionPolicyClient /// Retrieve Session Policy
/// Retrieve session timeout policy for the currently active 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 GetAsync( + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ISessionPolicyClient.Update.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ISessionPolicyClient.Update.g.cs index 3f053ec..fd5e5ea 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ISessionPolicyClient.Update.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ISessionPolicyClient.Update.g.cs @@ -9,11 +9,13 @@ public partial interface ISessionPolicyClient /// Update session timeout policy for the currently active 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 UpdateAsync( global::LabelStudio.PatchedSessionTimeoutPolicyRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Update Session Policy
@@ -25,11 +27,13 @@ public partial interface ISessionPolicyClient /// /// Number of minutes that a session stays active without any activity /// + /// 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 UpdateAsync( int? maxSessionAge = default, int? maxTimeBetweenActivity = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ISessionPolicyClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ISessionPolicyClient.g.cs index beb21ab..26d0e50 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ISessionPolicyClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ISessionPolicyClient.g.cs @@ -33,6 +33,11 @@ public partial interface ISessionPolicyClient : global::System.IDisposable ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ISsoClient.Get.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ISsoClient.Get.g.cs index ae0d20f..cad61d9 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ISsoClient.Get.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ISsoClient.Get.g.cs @@ -14,9 +14,11 @@ public partial interface ISsoClient /// </Card>
/// Retrieve SAML2 settings for the currently active 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 GetAsync( + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ISsoClient.Get2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ISsoClient.Get2.g.cs index c2adda0..37e83f5 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ISsoClient.Get2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ISsoClient.Get2.g.cs @@ -14,9 +14,11 @@ public partial interface ISsoClient /// </Card>
/// Retrieve SCIM settings for the currently active 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 Get2Async( + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ISsoClient.Reset.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ISsoClient.Reset.g.cs index f6b8a2a..160414b 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ISsoClient.Reset.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ISsoClient.Reset.g.cs @@ -14,9 +14,11 @@ public partial interface ISsoClient /// </Card>
/// Reset SAML2 settings for the currently active organization. This clears all configured fields (domain, metadata, attribute mappings, group mappings) back to their defaults without deleting the underlying settings record. /// + /// 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 ResetAsync( + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ISsoClient.Update.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ISsoClient.Update.g.cs index b4b3333..24efe5c 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ISsoClient.Update.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ISsoClient.Update.g.cs @@ -15,11 +15,13 @@ public partial interface ISsoClient /// Update SAML2 settings for the currently active 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 UpdateAsync( global::LabelStudio.SamlSettingsUpdateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Update SAML2 Settings
@@ -67,6 +69,7 @@ public partial interface ISsoClient /// /// Workspaces to Groups Mapping. List of [workspace_title, group_name] 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 UpdateAsync( @@ -82,6 +85,7 @@ public partial interface ISsoClient global::System.Collections.Generic.IList? projectsGroups = default, global::System.Collections.Generic.IList>? rolesGroups = default, global::System.Collections.Generic.IList>? workspacesGroups = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ISsoClient.Update2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ISsoClient.Update2.g.cs index 96e485f..abc7054 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ISsoClient.Update2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ISsoClient.Update2.g.cs @@ -15,11 +15,13 @@ public partial interface ISsoClient /// Update SCIM settings for the currently active 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 Update2Async( global::LabelStudio.ScimSettingsUpdateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Update SCIM Settings
@@ -40,12 +42,14 @@ public partial interface ISsoClient /// /// Workspaces to Groups Mapping. List of [workspace_title, group_name] 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 Update2Async( global::System.Collections.Generic.IList? projectsGroups = default, global::System.Collections.Generic.IList>? rolesGroups = default, global::System.Collections.Generic.IList>? workspacesGroups = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ISsoClient.ValidateMetadataUrl.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ISsoClient.ValidateMetadataUrl.g.cs index e3a9328..b3003fc 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ISsoClient.ValidateMetadataUrl.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ISsoClient.ValidateMetadataUrl.g.cs @@ -15,11 +15,13 @@ public partial interface ISsoClient /// Validate a SAML metadata URL by fetching it and checking for valid XML, without saving. ///
/// + /// 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 ValidateMetadataUrlAsync( global::LabelStudio.ValidateSamlMetadataUrlRequestRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Validate SAML Metadata URL
@@ -32,10 +34,12 @@ public partial interface ISsoClient /// Validate a SAML metadata URL by fetching it and checking for valid XML, without saving. ///
/// + /// 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 ValidateMetadataUrlAsync( string metadataUrl, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ISsoClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ISsoClient.g.cs index aafe712..142b471 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ISsoClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ISsoClient.g.cs @@ -33,6 +33,11 @@ public partial interface ISsoClient : global::System.IDisposable /// public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStatesClient.CancelBackfill.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStatesClient.CancelBackfill.g.cs index 3ce01f3..0823dc3 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStatesClient.CancelBackfill.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStatesClient.CancelBackfill.g.cs @@ -16,11 +16,13 @@ public partial interface IStatesClient /// /// /// + /// 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 CancelBackfillAsync( int? jobId = default, int? projectId = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStatesClient.ExecuteTransition.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStatesClient.ExecuteTransition.g.cs index fbe9353..60aa2a9 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStatesClient.ExecuteTransition.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStatesClient.ExecuteTransition.g.cs @@ -17,6 +17,7 @@ public partial interface IStatesClient /// /// /// + /// 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 ExecuteTransitionAsync( @@ -24,6 +25,7 @@ public partial interface IStatesClient string entityName, global::LabelStudio.FSMTransitionExecuteRequestRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Execute manual state transition
@@ -39,6 +41,7 @@ public partial interface IStatesClient /// /// /// + /// 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 ExecuteTransitionAsync( @@ -46,6 +49,7 @@ public partial interface IStatesClient string entityName, string transitionName, object? transitionData = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStatesClient.GetBackfillStatus.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStatesClient.GetBackfillStatus.g.cs index 435a3f0..8ce3dcf 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStatesClient.GetBackfillStatus.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStatesClient.GetBackfillStatus.g.cs @@ -16,11 +16,13 @@ public partial interface IStatesClient ///
/// /// + /// 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 GetBackfillStatusAsync( int? jobId = default, int? projectId = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStatesClient.ListBackfills.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStatesClient.ListBackfills.g.cs index 9c390ff..9ff31de 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStatesClient.ListBackfills.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStatesClient.ListBackfills.g.cs @@ -14,9 +14,11 @@ public partial interface IStatesClient /// </Card>
/// Retrieve the latest 10 state backfill jobs for the authenticated user's active organization. Shows job history with status, progress, and timing information. Requires administrator or owner role and both FSM feature flags (fflag_feat_fit_568_finite_state_management and fflag_feat_fit_710_fsm_state_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 ListBackfillsAsync( + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStatesClient.StateHistory.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStatesClient.StateHistory.g.cs index 945eb26..8b83abe 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStatesClient.StateHistory.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStatesClient.StateHistory.g.cs @@ -25,6 +25,7 @@ public partial interface IStatesClient /// /// /// + /// 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 StateHistoryAsync( @@ -39,6 +40,7 @@ public partial interface IStatesClient string? state = default, string? transitionName = default, double? triggeredBy = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStatesClient.TriggerBackfill.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStatesClient.TriggerBackfill.g.cs index 0fad914..2122cc5 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStatesClient.TriggerBackfill.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStatesClient.TriggerBackfill.g.cs @@ -15,10 +15,12 @@ public partial interface IStatesClient /// Trigger state backfill for the authenticated user's active organization. Creates initial state records for entities without states. Requires administrator or owner role and both FSM feature flags (fflag_feat_fit_568_finite_state_management and fflag_feat_fit_710_fsm_state_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 TriggerBackfillAsync( int? projectId = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStatesClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStatesClient.g.cs index 96c861b..498dd12 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStatesClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStatesClient.g.cs @@ -33,6 +33,11 @@ public partial interface IStatesClient : global::System.IDisposable /// public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.AgreementAnnotator.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.AgreementAnnotator.g.cs index 153323c..54ec2bc 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.AgreementAnnotator.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.AgreementAnnotator.g.cs @@ -16,11 +16,13 @@ public partial interface IStatsClient /// /// /// + /// 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 AgreementAnnotatorAsync( int id, int userId, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.AgreementAnnotators.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.AgreementAnnotators.g.cs index d82d26a..96f714c 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.AgreementAnnotators.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.AgreementAnnotators.g.cs @@ -16,11 +16,13 @@ public partial interface IStatsClient /// /// /// + /// 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 AgreementAnnotatorsAsync( int id, string ids, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.DataFilters.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.DataFilters.g.cs index ab1718b..b35542b 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.DataFilters.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.DataFilters.g.cs @@ -15,10 +15,12 @@ public partial interface IStatsClient /// Get statistics about user data filters and their usage within a project. /// /// + /// 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 DataFiltersAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.FinishedTasks.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.FinishedTasks.g.cs index 375d69c..f2ad807 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.FinishedTasks.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.FinishedTasks.g.cs @@ -16,11 +16,13 @@ public partial interface IStatsClient /// /// /// + /// 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 FinishedTasksAsync( int id, int? userPk = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.Iaa.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.Iaa.g.cs index 30b6b5f..2c0df6f 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.Iaa.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.Iaa.g.cs @@ -23,6 +23,7 @@ public partial interface IStatsClient /// 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 IaaAsync( @@ -31,6 +32,7 @@ public partial interface IStatsClient bool? perLabel = default, bool? std = default, string? task = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.LabelDistributionCounts.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.LabelDistributionCounts.g.cs index ba484e3..e0fa185 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.LabelDistributionCounts.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.LabelDistributionCounts.g.cs @@ -20,6 +20,7 @@ public partial interface IStatsClient /// /// 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 LabelDistributionCountsAsync( @@ -27,6 +28,7 @@ public partial interface IStatsClient string? choiceKeys = default, int? limit = default, int? offset = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.LabelDistributionStructure.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.LabelDistributionStructure.g.cs index 86927c9..6cb3d5e 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.LabelDistributionStructure.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.LabelDistributionStructure.g.cs @@ -15,10 +15,12 @@ public partial interface IStatsClient /// Returns dimensions and flattened `choice_keys` for a project. Use this response to drive paginated or targeted calls to the label distribution counts endpoint. /// /// + /// 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 LabelDistributionStructureAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.LeadTime.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.LeadTime.g.cs index bcf9e7a..47a7d49 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.LeadTime.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.LeadTime.g.cs @@ -15,10 +15,12 @@ public partial interface IStatsClient /// Get lead time statistics across the project, including average annotation time. /// /// + /// 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 LeadTimeAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.ModelVersionAnnotatorAgreement.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.ModelVersionAnnotatorAgreement.g.cs index 04a2ba6..7131117 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.ModelVersionAnnotatorAgreement.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.ModelVersionAnnotatorAgreement.g.cs @@ -16,11 +16,13 @@ public partial interface IStatsClient /// /// /// + /// 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 ModelVersionAnnotatorAgreementAsync( int id, string modelVersion, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.ModelVersionGroundTruthAgreement.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.ModelVersionGroundTruthAgreement.g.cs index 62a82d3..52f3277 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.ModelVersionGroundTruthAgreement.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.ModelVersionGroundTruthAgreement.g.cs @@ -19,12 +19,14 @@ public partial interface IStatsClient /// /// 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 ModelVersionGroundTruthAgreementAsync( int id, string modelVersion, bool? perLabel = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.ModelVersionPredictionAgreement.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.ModelVersionPredictionAgreement.g.cs index c3ac842..72ea503 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.ModelVersionPredictionAgreement.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.ModelVersionPredictionAgreement.g.cs @@ -19,12 +19,14 @@ public partial interface IStatsClient /// /// 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 ModelVersionPredictionAgreementAsync( int id, string modelVersion, bool? perLabel = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.TotalAgreement.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.TotalAgreement.g.cs index 005b9a2..0851257 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.TotalAgreement.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.TotalAgreement.g.cs @@ -17,11 +17,13 @@ public partial interface IStatsClient /// /// /// + /// 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> TotalAgreementAsync( int id, bool? perLabel = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.UpdateStats.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.UpdateStats.g.cs index 241d99e..e3a1d46 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.UpdateStats.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.UpdateStats.g.cs @@ -16,11 +16,13 @@ public partial interface IStatsClient /// /// /// + /// 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 UpdateStatsAsync( int id, string? statType = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.UserGroundTruthAgreement.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.UserGroundTruthAgreement.g.cs index 6116873..f0f0e50 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.UserGroundTruthAgreement.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.UserGroundTruthAgreement.g.cs @@ -17,12 +17,14 @@ public partial interface IStatsClient /// /// /// + /// 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 UserGroundTruthAgreementAsync( int id, int userPk, bool? perLabel = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.UserPredictionAgreement.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.UserPredictionAgreement.g.cs index a18bf6a..d7841bc 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.UserPredictionAgreement.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.UserPredictionAgreement.g.cs @@ -17,12 +17,14 @@ public partial interface IStatsClient /// /// /// + /// 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 UserPredictionAgreementAsync( int id, int userPk, bool? perLabel = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.UserReviewScore.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.UserReviewScore.g.cs index 7818f09..b0d68b1 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.UserReviewScore.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.UserReviewScore.g.cs @@ -17,12 +17,14 @@ public partial interface IStatsClient /// /// /// + /// 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 UserReviewScoreAsync( int id, int userPk, bool? perLabel = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.UsersGroundTruthAgreement.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.UsersGroundTruthAgreement.g.cs index c34b934..32c22ec 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.UsersGroundTruthAgreement.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.UsersGroundTruthAgreement.g.cs @@ -19,12 +19,14 @@ public partial interface IStatsClient /// /// 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 UsersGroundTruthAgreementAsync( int id, string ids, bool? perLabel = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.UsersPredictionAgreement.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.UsersPredictionAgreement.g.cs index 2849a92..7437eb0 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.UsersPredictionAgreement.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.UsersPredictionAgreement.g.cs @@ -19,12 +19,14 @@ public partial interface IStatsClient /// /// 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 UsersPredictionAgreementAsync( int id, string ids, bool? perLabel = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.UsersReviewScore.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.UsersReviewScore.g.cs index 170da38..3c25598 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.UsersReviewScore.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.UsersReviewScore.g.cs @@ -17,12 +17,14 @@ public partial interface IStatsClient /// /// /// + /// 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 UsersReviewScoreAsync( int id, string ids, bool? perLabel = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.g.cs index 494ece2..3f46ab2 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStatsClient.g.cs @@ -33,6 +33,11 @@ public partial interface IStatsClient : global::System.IDisposable /// public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureClient.Create.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureClient.Create.g.cs index de38254..1f203dd 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureClient.Create.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureClient.Create.g.cs @@ -9,11 +9,13 @@ public partial interface IStorageAzureClient /// Create new Azure import 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 CreateAsync( global::LabelStudio.ApiStoragesAzureCreateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Create new storage
@@ -55,6 +57,7 @@ public partial interface IStorageAzureClient /// Interpret objects as BLOBs and generate URLs. For example, if your bucket contains images, you can use this option to generate URLs for these images. If set to False, it will read the content of the file and load it into Label Studio.
/// 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 CreateAsync( @@ -69,6 +72,7 @@ public partial interface IStorageAzureClient string? regexFilter = default, string? title = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureClient.Create2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureClient.Create2.g.cs index bc5094b..23d4c06 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureClient.Create2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureClient.Create2.g.cs @@ -9,11 +9,13 @@ public partial interface IStorageAzureClient /// Create a new Azure export storage connection to store annotations. ///
/// + /// 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 Create2Async( global::LabelStudio.ApiStoragesExportAzureCreateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Create export storage
@@ -44,6 +46,7 @@ public partial interface IStorageAzureClient /// /// Storage title /// + /// 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 Create2Async( @@ -55,6 +58,7 @@ public partial interface IStorageAzureClient string? prefix = default, int? project = default, string? title = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureClient.Delete.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureClient.Delete.g.cs index 4c88b9c..1f997fb 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureClient.Delete.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureClient.Delete.g.cs @@ -9,10 +9,12 @@ public partial interface IStorageAzureClient /// Delete a specific Azure import storage connection. ///
/// + /// 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 DeleteAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureClient.Delete2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureClient.Delete2.g.cs index 2c68778..e88e4f2 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureClient.Delete2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureClient.Delete2.g.cs @@ -9,10 +9,12 @@ public partial interface IStorageAzureClient /// Delete a specific Azure export storage connection. /// /// + /// 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 Delete2Async( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureClient.Get.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureClient.Get.g.cs index 1c11288..be8b92f 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureClient.Get.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureClient.Get.g.cs @@ -9,10 +9,12 @@ public partial interface IStorageAzureClient /// Get a specific Azure import storage connection. /// /// + /// 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 GetAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureClient.Get2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureClient.Get2.g.cs index 7c29a8e..a725f95 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureClient.Get2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureClient.Get2.g.cs @@ -9,10 +9,12 @@ public partial interface IStorageAzureClient /// Get a specific Azure export storage connection. /// /// + /// 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 Get2Async( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureClient.List.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureClient.List.g.cs index 87eb75f..79bae50 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureClient.List.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureClient.List.g.cs @@ -10,11 +10,13 @@ public partial interface IStorageAzureClient /// /// /// + /// 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> ListAsync( int project, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureClient.List2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureClient.List2.g.cs index b0b35fe..b03a7c8 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureClient.List2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureClient.List2.g.cs @@ -10,11 +10,13 @@ public partial interface IStorageAzureClient /// /// /// + /// 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> List2Async( int project, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureClient.Sync.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureClient.Sync.g.cs index 3cc1bac..46d9c09 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureClient.Sync.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureClient.Sync.g.cs @@ -9,10 +9,12 @@ public partial interface IStorageAzureClient /// Sync tasks from an Azure import storage connection. /// /// + /// 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 SyncAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureClient.Sync2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureClient.Sync2.g.cs index 94fe58a..637c5b8 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureClient.Sync2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureClient.Sync2.g.cs @@ -9,10 +9,12 @@ public partial interface IStorageAzureClient /// Sync tasks from an Azure export storage connection. /// /// + /// 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 Sync2Async( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureClient.Update.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureClient.Update.g.cs index f9d338c..28a2b7d 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureClient.Update.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureClient.Update.g.cs @@ -10,12 +10,14 @@ public partial interface IStorageAzureClient /// /// /// + /// 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 UpdateAsync( int id, global::LabelStudio.ApiStoragesAzurePartialUpdateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Update import storage
@@ -58,6 +60,7 @@ public partial interface IStorageAzureClient /// Interpret objects as BLOBs and generate URLs. For example, if your bucket contains images, you can use this option to generate URLs for these images. If set to False, it will read the content of the file and load it into Label Studio.
/// 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 UpdateAsync( @@ -73,6 +76,7 @@ public partial interface IStorageAzureClient string? regexFilter = default, string? title = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureClient.Update2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureClient.Update2.g.cs index e0b4dec..0a3125a 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureClient.Update2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureClient.Update2.g.cs @@ -10,12 +10,14 @@ public partial interface IStorageAzureClient ///
/// /// + /// 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 Update2Async( int id, global::LabelStudio.ApiStoragesExportAzurePartialUpdateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Update export storage
@@ -47,6 +49,7 @@ public partial interface IStorageAzureClient /// /// Storage title /// + /// 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 Update2Async( @@ -59,6 +62,7 @@ public partial interface IStorageAzureClient string? prefix = default, int? project = default, string? title = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureClient.Validate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureClient.Validate.g.cs index 88550dc..8170918 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureClient.Validate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureClient.Validate.g.cs @@ -9,11 +9,13 @@ public partial interface IStorageAzureClient /// Validate a specific Azure import storage connection. ///
/// + /// 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 ValidateAsync( global::LabelStudio.ApiStoragesAzureValidateCreateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Validate import storage
@@ -58,6 +60,7 @@ public partial interface IStorageAzureClient /// Interpret objects as BLOBs and generate URLs. For example, if your bucket contains images, you can use this option to generate URLs for these images. If set to False, it will read the content of the file and load it into Label Studio.
/// 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 ValidateAsync( @@ -73,6 +76,7 @@ public partial interface IStorageAzureClient string? regexFilter = default, string? title = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureClient.Validate2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureClient.Validate2.g.cs index 120f2a2..6a41d30 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureClient.Validate2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureClient.Validate2.g.cs @@ -9,11 +9,13 @@ public partial interface IStorageAzureClient /// Validate a specific Azure export storage connection. ///
/// + /// 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 Validate2Async( global::LabelStudio.ApiStoragesExportAzureValidateCreateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Validate export storage
@@ -47,6 +49,7 @@ public partial interface IStorageAzureClient /// /// Storage title /// + /// 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 Validate2Async( @@ -59,6 +62,7 @@ public partial interface IStorageAzureClient string? prefix = default, int? project = default, string? title = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureClient.g.cs index abcfa00..048e85b 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureClient.g.cs @@ -33,6 +33,11 @@ public partial interface IStorageAzureClient : global::System.IDisposable ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureSpiClient.Create.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureSpiClient.Create.g.cs index 8fc2e8c..15d7781 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureSpiClient.Create.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureSpiClient.Create.g.cs @@ -15,11 +15,13 @@ public partial interface IStorageAzureSpiClient /// Create Azure import storage with Service Principal authentication. /// /// + /// 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 CreateAsync( global::LabelStudio.AzureServicePrincipalImportStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Create Azure import storage with SPI
@@ -102,6 +104,7 @@ public partial interface IStorageAzureSpiClient /// /// User Delegation Key (Backend) /// + /// 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 CreateAsync( @@ -127,6 +130,7 @@ public partial interface IStorageAzureSpiClient string? traceback = default, bool? useBlobUrls = default, string? userDelegationKey = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureSpiClient.Create2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureSpiClient.Create2.g.cs index f8c8865..38cf699 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureSpiClient.Create2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureSpiClient.Create2.g.cs @@ -15,11 +15,13 @@ public partial interface IStorageAzureSpiClient /// Create an Azure export storage connection with Service Principal authentication to store annotations. ///
/// + /// 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 Create2Async( global::LabelStudio.AzureServicePrincipalExportStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Create Azure export storage with SPI authentication
@@ -96,6 +98,7 @@ public partial interface IStorageAzureSpiClient /// /// User Delegation Key (Backend) /// + /// 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 Create2Async( @@ -119,6 +122,7 @@ public partial interface IStorageAzureSpiClient string? traceback = default, bool? useBlobUrls = default, string? userDelegationKey = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureSpiClient.Delete.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureSpiClient.Delete.g.cs index c5d6769..7e32232 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureSpiClient.Delete.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureSpiClient.Delete.g.cs @@ -15,10 +15,12 @@ public partial interface IStorageAzureSpiClient /// Delete a specific Azure import storage connection that was set up with Service Principal authentication. ///
/// + /// 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 DeleteAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureSpiClient.Delete2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureSpiClient.Delete2.g.cs index 59a5d56..ce64287 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureSpiClient.Delete2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureSpiClient.Delete2.g.cs @@ -15,10 +15,12 @@ public partial interface IStorageAzureSpiClient /// Delete a specific Azure export storage connection that was set up with Service Principal authentication. /// /// + /// 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 Delete2Async( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureSpiClient.Get.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureSpiClient.Get.g.cs index b2f4d7c..97aecc1 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureSpiClient.Get.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureSpiClient.Get.g.cs @@ -15,10 +15,12 @@ public partial interface IStorageAzureSpiClient /// Get a specific Azure import storage connection that was set up with Service Principal authentication. /// /// + /// 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 GetAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureSpiClient.Get2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureSpiClient.Get2.g.cs index e99f4d6..5bad7dd 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureSpiClient.Get2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureSpiClient.Get2.g.cs @@ -15,10 +15,12 @@ public partial interface IStorageAzureSpiClient /// Get a specific Azure export storage connection that was set up with Service Principal authentication. /// /// + /// 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 Get2Async( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureSpiClient.List.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureSpiClient.List.g.cs index 07353db..8923fca 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureSpiClient.List.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureSpiClient.List.g.cs @@ -16,11 +16,13 @@ public partial interface IStorageAzureSpiClient /// /// /// + /// 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> ListAsync( int project, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureSpiClient.List2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureSpiClient.List2.g.cs index fbc774b..d0e281a 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureSpiClient.List2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureSpiClient.List2.g.cs @@ -16,11 +16,13 @@ public partial interface IStorageAzureSpiClient /// /// /// + /// 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> List2Async( int project, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureSpiClient.Sync.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureSpiClient.Sync.g.cs index e3385e7..2f15afd 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureSpiClient.Sync.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureSpiClient.Sync.g.cs @@ -15,10 +15,12 @@ public partial interface IStorageAzureSpiClient /// Sync tasks from an Azure import storage connection that was set up with Service Principal authentication. /// /// + /// 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 SyncAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureSpiClient.Sync2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureSpiClient.Sync2.g.cs index 776d667..d5e0f38 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureSpiClient.Sync2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureSpiClient.Sync2.g.cs @@ -15,10 +15,12 @@ public partial interface IStorageAzureSpiClient /// Sync tasks from an Azure SPI export 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 Sync2Async( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureSpiClient.Update.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureSpiClient.Update.g.cs index 5a275a8..a75bb2b 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureSpiClient.Update.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureSpiClient.Update.g.cs @@ -16,12 +16,14 @@ public partial interface IStorageAzureSpiClient /// /// /// + /// 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 UpdateAsync( int id, global::LabelStudio.PatchedAzureServicePrincipalImportStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Update Azure SPI import storage
@@ -105,6 +107,7 @@ public partial interface IStorageAzureSpiClient /// /// User Delegation Key (Backend) /// + /// 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 UpdateAsync( @@ -131,6 +134,7 @@ public partial interface IStorageAzureSpiClient string? traceback = default, bool? useBlobUrls = default, string? userDelegationKey = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureSpiClient.Update2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureSpiClient.Update2.g.cs index c47a3a1..877869e 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureSpiClient.Update2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureSpiClient.Update2.g.cs @@ -16,12 +16,14 @@ public partial interface IStorageAzureSpiClient ///
/// /// + /// 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 Update2Async( int id, global::LabelStudio.PatchedAzureServicePrincipalExportStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Update Azure SPI export storage
@@ -99,6 +101,7 @@ public partial interface IStorageAzureSpiClient /// /// User Delegation Key (Backend) /// + /// 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 Update2Async( @@ -123,6 +126,7 @@ public partial interface IStorageAzureSpiClient string? traceback = default, bool? useBlobUrls = default, string? userDelegationKey = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureSpiClient.Validate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureSpiClient.Validate.g.cs index c0a6676..e160e80 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureSpiClient.Validate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureSpiClient.Validate.g.cs @@ -15,11 +15,13 @@ public partial interface IStorageAzureSpiClient /// Validate a specific Azure import storage connection that was set up with Service Principal authentication. ///
/// + /// 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 ValidateAsync( global::LabelStudio.AzureServicePrincipalImportStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Validate Azure SPI import storage
@@ -102,6 +104,7 @@ public partial interface IStorageAzureSpiClient /// /// User Delegation Key (Backend) /// + /// 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 ValidateAsync( @@ -127,6 +130,7 @@ public partial interface IStorageAzureSpiClient string? traceback = default, bool? useBlobUrls = default, string? userDelegationKey = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureSpiClient.Validate2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureSpiClient.Validate2.g.cs index c6ecccb..22fbdbf 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureSpiClient.Validate2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureSpiClient.Validate2.g.cs @@ -15,11 +15,13 @@ public partial interface IStorageAzureSpiClient /// Validate a specific Azure export storage connection that was set up with Service Principal authentication. ///
/// + /// 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 Validate2Async( global::LabelStudio.AzureServicePrincipalExportStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Validate Azure SPI export storage
@@ -96,6 +98,7 @@ public partial interface IStorageAzureSpiClient /// /// User Delegation Key (Backend) /// + /// 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 Validate2Async( @@ -119,6 +122,7 @@ public partial interface IStorageAzureSpiClient string? traceback = default, bool? useBlobUrls = default, string? userDelegationKey = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureSpiClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureSpiClient.g.cs index ff6c299..106bec0 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureSpiClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageAzureSpiClient.g.cs @@ -33,6 +33,11 @@ public partial interface IStorageAzureSpiClient : global::System.IDisposable ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageClient.ApiDatasetStoragesList.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageClient.ApiDatasetStoragesList.g.cs index 194b23b..dafcd6e 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageClient.ApiDatasetStoragesList.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageClient.ApiDatasetStoragesList.g.cs @@ -9,10 +9,12 @@ public partial interface IStorageClient /// Retrieve a list of the dataset storages of all types with their 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 ApiDatasetStoragesListAsync( string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageClient.ApiDatasetStoragesTypesRetrieve.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageClient.ApiDatasetStoragesTypesRetrieve.g.cs index d2a947a..9080fa3 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageClient.ApiDatasetStoragesTypesRetrieve.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageClient.ApiDatasetStoragesTypesRetrieve.g.cs @@ -8,9 +8,11 @@ public partial interface IStorageClient /// List all dataset storages types
/// Retrieve a list of the dataset storages types. /// + /// 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 ApiDatasetStoragesTypesRetrieveAsync( + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageClient.List.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageClient.List.g.cs index e9a60bf..195bed5 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageClient.List.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageClient.List.g.cs @@ -9,10 +9,12 @@ public partial interface IStorageClient /// Retrieve a list of the import storages of all types with their 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> ListAsync( string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageClient.List2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageClient.List2.g.cs index 2d5a5cd..2be47c9 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageClient.List2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageClient.List2.g.cs @@ -9,10 +9,12 @@ public partial interface IStorageClient /// Retrieve a list of the export storages of all types with their 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> List2Async( string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageClient.ListTypes.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageClient.ListTypes.g.cs index 4fc4819..17aa790 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageClient.ListTypes.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageClient.ListTypes.g.cs @@ -8,9 +8,11 @@ public partial interface IStorageClient /// List all export storages types
/// Retrieve a list of the export storages types. /// + /// 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> ListTypesAsync( + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageClient.ListTypes2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageClient.ListTypes2.g.cs index a7b9820..dd272fb 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageClient.ListTypes2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageClient.ListTypes2.g.cs @@ -8,9 +8,11 @@ public partial interface IStorageClient /// List all import storages types
/// Retrieve a list of the import storages types. /// + /// 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> ListTypes2Async( + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageClient.g.cs index 58298c3..674c26e 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageClient.g.cs @@ -33,6 +33,11 @@ public partial interface IStorageClient : global::System.IDisposable /// public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageDatabricksFilesClient.Create.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageDatabricksFilesClient.Create.g.cs index 507c075..cec4561 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageDatabricksFilesClient.Create.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageDatabricksFilesClient.Create.g.cs @@ -15,11 +15,13 @@ public partial interface IStorageDatabricksFilesClient /// Create a Databricks Files import storage connection. /// /// + /// 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 CreateAsync( global::LabelStudio.DatabricksImportStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Create Databricks import storage
@@ -122,6 +124,7 @@ public partial interface IStorageDatabricksFilesClient /// /// UC volume name /// + /// 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 CreateAsync( @@ -153,6 +156,7 @@ public partial interface IStorageDatabricksFilesClient string? traceback = default, bool? useBlobUrls = default, bool? verifyTls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageDatabricksFilesClient.Create2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageDatabricksFilesClient.Create2.g.cs index d80dc93..9e4436d 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageDatabricksFilesClient.Create2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageDatabricksFilesClient.Create2.g.cs @@ -15,11 +15,13 @@ public partial interface IStorageDatabricksFilesClient /// Create a Databricks Files export storage connection. ///
/// + /// 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 Create2Async( global::LabelStudio.DatabricksExportStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Create Databricks export storage
@@ -116,6 +118,7 @@ public partial interface IStorageDatabricksFilesClient /// /// UC volume name /// + /// 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 Create2Async( @@ -145,6 +148,7 @@ public partial interface IStorageDatabricksFilesClient string? traceback = default, bool? useBlobUrls = default, bool? verifyTls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageDatabricksFilesClient.Delete.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageDatabricksFilesClient.Delete.g.cs index 386c9b6..ff6f3ec 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageDatabricksFilesClient.Delete.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageDatabricksFilesClient.Delete.g.cs @@ -15,10 +15,12 @@ public partial interface IStorageDatabricksFilesClient /// Delete a specific Databricks Files import storage connection. ///
/// + /// 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 DeleteAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageDatabricksFilesClient.Delete2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageDatabricksFilesClient.Delete2.g.cs index d3bd0c4..e037b5e 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageDatabricksFilesClient.Delete2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageDatabricksFilesClient.Delete2.g.cs @@ -15,10 +15,12 @@ public partial interface IStorageDatabricksFilesClient /// Delete a specific Databricks Files export storage connection. /// /// + /// 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 Delete2Async( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageDatabricksFilesClient.Get.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageDatabricksFilesClient.Get.g.cs index c727fa7..58d3a0f 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageDatabricksFilesClient.Get.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageDatabricksFilesClient.Get.g.cs @@ -15,10 +15,12 @@ public partial interface IStorageDatabricksFilesClient /// Get a specific Databricks Files import storage connection. /// /// + /// 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 GetAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageDatabricksFilesClient.Get2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageDatabricksFilesClient.Get2.g.cs index 08a0a0b..a3e991d 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageDatabricksFilesClient.Get2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageDatabricksFilesClient.Get2.g.cs @@ -15,10 +15,12 @@ public partial interface IStorageDatabricksFilesClient /// Get a specific Databricks Files export storage connection. /// /// + /// 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 Get2Async( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageDatabricksFilesClient.List.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageDatabricksFilesClient.List.g.cs index ddbe942..6287cbc 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageDatabricksFilesClient.List.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageDatabricksFilesClient.List.g.cs @@ -16,11 +16,13 @@ public partial interface IStorageDatabricksFilesClient /// /// /// + /// 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> ListAsync( int project, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageDatabricksFilesClient.List2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageDatabricksFilesClient.List2.g.cs index c2fca50..e162e49 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageDatabricksFilesClient.List2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageDatabricksFilesClient.List2.g.cs @@ -16,11 +16,13 @@ public partial interface IStorageDatabricksFilesClient /// /// /// + /// 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> List2Async( int project, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageDatabricksFilesClient.Sync.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageDatabricksFilesClient.Sync.g.cs index 72a50a0..018f4b7 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageDatabricksFilesClient.Sync.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageDatabricksFilesClient.Sync.g.cs @@ -15,10 +15,12 @@ public partial interface IStorageDatabricksFilesClient /// Sync tasks from a Databricks Files import 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 SyncAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageDatabricksFilesClient.Sync2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageDatabricksFilesClient.Sync2.g.cs index ab6b37f..6cca9e9 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageDatabricksFilesClient.Sync2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageDatabricksFilesClient.Sync2.g.cs @@ -15,10 +15,12 @@ public partial interface IStorageDatabricksFilesClient /// Export annotations to a Databricks Files 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 Sync2Async( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageDatabricksFilesClient.Update.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageDatabricksFilesClient.Update.g.cs index 1bccd14..e036798 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageDatabricksFilesClient.Update.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageDatabricksFilesClient.Update.g.cs @@ -16,12 +16,14 @@ public partial interface IStorageDatabricksFilesClient /// /// /// + /// 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 UpdateAsync( int id, global::LabelStudio.PatchedDatabricksImportStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Update Databricks import storage
@@ -125,6 +127,7 @@ public partial interface IStorageDatabricksFilesClient /// /// UC volume name /// + /// 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 UpdateAsync( @@ -157,6 +160,7 @@ public partial interface IStorageDatabricksFilesClient bool? useBlobUrls = default, bool? verifyTls = default, string? volume = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageDatabricksFilesClient.Update2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageDatabricksFilesClient.Update2.g.cs index 01b8a80..cc012f2 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageDatabricksFilesClient.Update2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageDatabricksFilesClient.Update2.g.cs @@ -16,12 +16,14 @@ public partial interface IStorageDatabricksFilesClient ///
/// /// + /// 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 Update2Async( int id, global::LabelStudio.PatchedDatabricksExportStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Update Databricks export storage
@@ -119,6 +121,7 @@ public partial interface IStorageDatabricksFilesClient /// /// UC volume name /// + /// 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 Update2Async( @@ -149,6 +152,7 @@ public partial interface IStorageDatabricksFilesClient bool? useBlobUrls = default, bool? verifyTls = default, string? volume = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageDatabricksFilesClient.Validate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageDatabricksFilesClient.Validate.g.cs index cb5826b..3b13ba3 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageDatabricksFilesClient.Validate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageDatabricksFilesClient.Validate.g.cs @@ -15,11 +15,13 @@ public partial interface IStorageDatabricksFilesClient /// Validate a specific Databricks Files import storage connection. ///
/// + /// 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 ValidateAsync( global::LabelStudio.DatabricksImportStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Validate Databricks import storage
@@ -122,6 +124,7 @@ public partial interface IStorageDatabricksFilesClient /// /// UC volume name /// + /// 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 ValidateAsync( @@ -153,6 +156,7 @@ public partial interface IStorageDatabricksFilesClient string? traceback = default, bool? useBlobUrls = default, bool? verifyTls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageDatabricksFilesClient.Validate2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageDatabricksFilesClient.Validate2.g.cs index 89e3931..9455022 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageDatabricksFilesClient.Validate2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageDatabricksFilesClient.Validate2.g.cs @@ -15,11 +15,13 @@ public partial interface IStorageDatabricksFilesClient /// Validate a specific Databricks Files export storage connection. ///
/// + /// 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 Validate2Async( global::LabelStudio.DatabricksExportStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Validate Databricks export storage
@@ -116,6 +118,7 @@ public partial interface IStorageDatabricksFilesClient /// /// UC volume name /// + /// 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 Validate2Async( @@ -145,6 +148,7 @@ public partial interface IStorageDatabricksFilesClient string? traceback = default, bool? useBlobUrls = default, bool? verifyTls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageDatabricksFilesClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageDatabricksFilesClient.g.cs index 6b5752f..35d38bd 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageDatabricksFilesClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageDatabricksFilesClient.g.cs @@ -33,6 +33,11 @@ public partial interface IStorageDatabricksFilesClient : global::System.IDisposa ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsClient.Create.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsClient.Create.g.cs index 5df2206..590346f 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsClient.Create.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsClient.Create.g.cs @@ -9,11 +9,13 @@ public partial interface IStorageGcsClient /// Create a new GCS export storage connection to store annotations. /// /// + /// 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 CreateAsync( global::LabelStudio.ApiStoragesExportGcsCreateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Create export storage
@@ -44,6 +46,7 @@ public partial interface IStorageGcsClient /// /// Storage title /// + /// 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 CreateAsync( @@ -55,6 +58,7 @@ public partial interface IStorageGcsClient string? prefix = default, int? project = default, string? title = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsClient.Create2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsClient.Create2.g.cs index 2ec1a94..f23588c 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsClient.Create2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsClient.Create2.g.cs @@ -9,11 +9,13 @@ public partial interface IStorageGcsClient /// Create a new GCS import storage connection. ///
/// + /// 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 Create2Async( global::LabelStudio.ApiStoragesGcsCreateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Create import storage
@@ -55,6 +57,7 @@ public partial interface IStorageGcsClient /// Interpret objects as BLOBs and generate URLs. For example, if your bucket contains images, you can use this option to generate URLs for these images. If set to False, it will read the content of the file and load it into Label Studio.
/// 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 Create2Async( @@ -69,6 +72,7 @@ public partial interface IStorageGcsClient string? regexFilter = default, string? title = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsClient.Delete.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsClient.Delete.g.cs index ef4d828..7e06149 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsClient.Delete.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsClient.Delete.g.cs @@ -9,10 +9,12 @@ public partial interface IStorageGcsClient /// Delete a specific GCS export storage connection. ///
/// + /// 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 DeleteAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsClient.Delete2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsClient.Delete2.g.cs index 4d64f66..1f2837d 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsClient.Delete2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsClient.Delete2.g.cs @@ -9,10 +9,12 @@ public partial interface IStorageGcsClient /// Delete a specific GCS import storage connection. /// /// + /// 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 Delete2Async( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsClient.Get.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsClient.Get.g.cs index 5b7d7a6..39be852 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsClient.Get.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsClient.Get.g.cs @@ -9,10 +9,12 @@ public partial interface IStorageGcsClient /// Get a specific GCS export storage connection. /// /// + /// 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 GetAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsClient.Get2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsClient.Get2.g.cs index 58bda4b..975bbcf 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsClient.Get2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsClient.Get2.g.cs @@ -9,10 +9,12 @@ public partial interface IStorageGcsClient /// Get a specific GCS import storage connection. /// /// + /// 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 Get2Async( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsClient.List.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsClient.List.g.cs index 92789ef..fe30951 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsClient.List.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsClient.List.g.cs @@ -10,11 +10,13 @@ public partial interface IStorageGcsClient /// /// /// + /// 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> ListAsync( int project, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsClient.List2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsClient.List2.g.cs index 4d086d5..0fd5934 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsClient.List2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsClient.List2.g.cs @@ -10,11 +10,13 @@ public partial interface IStorageGcsClient /// /// /// + /// 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> List2Async( int project, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsClient.Sync.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsClient.Sync.g.cs index 95ffcab..c4ba9a1 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsClient.Sync.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsClient.Sync.g.cs @@ -9,10 +9,12 @@ public partial interface IStorageGcsClient /// Sync tasks from an GCS export storage connection. /// /// + /// 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 SyncAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsClient.Sync2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsClient.Sync2.g.cs index c29013e..f680415 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsClient.Sync2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsClient.Sync2.g.cs @@ -9,10 +9,12 @@ public partial interface IStorageGcsClient /// Sync tasks from a GCS import storage connection. /// /// + /// 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 Sync2Async( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsClient.Update.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsClient.Update.g.cs index 48e272d..a491643 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsClient.Update.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsClient.Update.g.cs @@ -10,12 +10,14 @@ public partial interface IStorageGcsClient /// /// /// + /// 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 UpdateAsync( int id, global::LabelStudio.ApiStoragesExportGcsPartialUpdateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Update export storage
@@ -47,6 +49,7 @@ public partial interface IStorageGcsClient /// /// Storage title /// + /// 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 UpdateAsync( @@ -59,6 +62,7 @@ public partial interface IStorageGcsClient string? prefix = default, int? project = default, string? title = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsClient.Update2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsClient.Update2.g.cs index 597bd48..dd2ec60 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsClient.Update2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsClient.Update2.g.cs @@ -10,12 +10,14 @@ public partial interface IStorageGcsClient ///
/// /// + /// 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 Update2Async( int id, global::LabelStudio.ApiStoragesGcsPartialUpdateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Update import storage
@@ -58,6 +60,7 @@ public partial interface IStorageGcsClient /// Interpret objects as BLOBs and generate URLs. For example, if your bucket contains images, you can use this option to generate URLs for these images. If set to False, it will read the content of the file and load it into Label Studio.
/// 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 Update2Async( @@ -73,6 +76,7 @@ public partial interface IStorageGcsClient string? regexFilter = default, string? title = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsClient.Validate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsClient.Validate.g.cs index 85023dc..becc2e2 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsClient.Validate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsClient.Validate.g.cs @@ -9,11 +9,13 @@ public partial interface IStorageGcsClient /// Validate a specific GCS export storage connection. ///
/// + /// 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 ValidateAsync( global::LabelStudio.ApiStoragesExportGcsValidateCreateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Validate export storage
@@ -47,6 +49,7 @@ public partial interface IStorageGcsClient /// /// Storage title /// + /// 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 ValidateAsync( @@ -59,6 +62,7 @@ public partial interface IStorageGcsClient string? prefix = default, int? project = default, string? title = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsClient.Validate2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsClient.Validate2.g.cs index ca5190a..152b375 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsClient.Validate2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsClient.Validate2.g.cs @@ -9,11 +9,13 @@ public partial interface IStorageGcsClient /// Validate a specific GCS import storage connection. ///
/// + /// 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 Validate2Async( global::LabelStudio.ApiStoragesGcsValidateCreateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Validate import storage
@@ -58,6 +60,7 @@ public partial interface IStorageGcsClient /// Interpret objects as BLOBs and generate URLs. For example, if your bucket contains images, you can use this option to generate URLs for these images. If set to False, it will read the content of the file and load it into Label Studio.
/// 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 Validate2Async( @@ -73,6 +76,7 @@ public partial interface IStorageGcsClient string? regexFilter = default, string? title = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsClient.g.cs index 687c765..bb4c1c3 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsClient.g.cs @@ -33,6 +33,11 @@ public partial interface IStorageGcsClient : global::System.IDisposable ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsSaClient.Create.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsSaClient.Create.g.cs index e0d1c11..912156e 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsSaClient.Create.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsSaClient.Create.g.cs @@ -15,11 +15,13 @@ public partial interface IStorageGcsSaClient /// Create a GCS export storage connection with SA Impersonation to store annotations. /// /// + /// 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 CreateAsync( global::LabelStudio.GCSSAExportStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Create GCS export storage with SA Impersonation
@@ -87,6 +89,7 @@ public partial interface IStorageGcsSaClient /// /// Interpret objects as BLOBs and generate URLs /// + /// 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 CreateAsync( @@ -107,6 +110,7 @@ public partial interface IStorageGcsSaClient string? title = default, string? traceback = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsSaClient.Create2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsSaClient.Create2.g.cs index 67254a3..2096d4e 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsSaClient.Create2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsSaClient.Create2.g.cs @@ -15,11 +15,13 @@ public partial interface IStorageGcsSaClient /// Create GCS import storage with Service Account Impersonation. ///
/// + /// 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 Create2Async( global::LabelStudio.GCSSAImportStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Create GCS import storage with SA Impersonation
@@ -93,6 +95,7 @@ public partial interface IStorageGcsSaClient /// /// Interpret objects as BLOBs and generate URLs /// + /// 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 Create2Async( @@ -115,6 +118,7 @@ public partial interface IStorageGcsSaClient string? title = default, string? traceback = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsSaClient.Delete.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsSaClient.Delete.g.cs index 0a2cce3..2fda773 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsSaClient.Delete.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsSaClient.Delete.g.cs @@ -15,10 +15,12 @@ public partial interface IStorageGcsSaClient /// Delete a specific GCS export storage connection set up with SA Impersonation. ///
/// + /// 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 DeleteAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsSaClient.Delete2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsSaClient.Delete2.g.cs index 4616c12..0b3540b 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsSaClient.Delete2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsSaClient.Delete2.g.cs @@ -15,10 +15,12 @@ public partial interface IStorageGcsSaClient /// Delete a specific GCS import storage connection set up with SA Impersonation. /// /// + /// 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 Delete2Async( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsSaClient.Get.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsSaClient.Get.g.cs index 8199910..27d0d17 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsSaClient.Get.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsSaClient.Get.g.cs @@ -15,10 +15,12 @@ public partial interface IStorageGcsSaClient /// Get a specific GCS export storage connection set up with SA Impersonation. /// /// + /// 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 GetAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsSaClient.Get2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsSaClient.Get2.g.cs index a8a6c71..ba731ef 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsSaClient.Get2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsSaClient.Get2.g.cs @@ -15,10 +15,12 @@ public partial interface IStorageGcsSaClient /// Get a specific GCS import storage connection set up with SA Impersonation. /// /// + /// 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 Get2Async( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsSaClient.List.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsSaClient.List.g.cs index fa07f3d..866446e 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsSaClient.List.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsSaClient.List.g.cs @@ -16,11 +16,13 @@ public partial interface IStorageGcsSaClient /// /// /// + /// 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> ListAsync( int project, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsSaClient.List2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsSaClient.List2.g.cs index ccf1f92..eecd1da 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsSaClient.List2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsSaClient.List2.g.cs @@ -16,11 +16,13 @@ public partial interface IStorageGcsSaClient /// /// /// + /// 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> List2Async( int project, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsSaClient.Sync.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsSaClient.Sync.g.cs index 691f18c..c97f16a 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsSaClient.Sync.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsSaClient.Sync.g.cs @@ -15,10 +15,12 @@ public partial interface IStorageGcsSaClient /// Sync annotations to a GCS SA export 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 SyncAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsSaClient.Sync2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsSaClient.Sync2.g.cs index 270394a..de49ea7 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsSaClient.Sync2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsSaClient.Sync2.g.cs @@ -15,10 +15,12 @@ public partial interface IStorageGcsSaClient /// Sync tasks from a GCS import storage connection set up with SA Impersonation. /// /// + /// 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 Sync2Async( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsSaClient.Update.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsSaClient.Update.g.cs index 0a08c7f..18b11fc 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsSaClient.Update.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsSaClient.Update.g.cs @@ -16,12 +16,14 @@ public partial interface IStorageGcsSaClient /// /// /// + /// 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 UpdateAsync( int id, global::LabelStudio.PatchedGCSSAExportStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Update GCS SA export storage
@@ -90,6 +92,7 @@ public partial interface IStorageGcsSaClient /// /// Interpret objects as BLOBs and generate URLs /// + /// 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 UpdateAsync( @@ -111,6 +114,7 @@ public partial interface IStorageGcsSaClient string? title = default, string? traceback = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsSaClient.Update2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsSaClient.Update2.g.cs index 6664a38..caa44a3 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsSaClient.Update2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsSaClient.Update2.g.cs @@ -16,12 +16,14 @@ public partial interface IStorageGcsSaClient ///
/// /// + /// 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 Update2Async( int id, global::LabelStudio.PatchedGCSSAImportStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Update GCS SA import storage
@@ -96,6 +98,7 @@ public partial interface IStorageGcsSaClient /// /// Interpret objects as BLOBs and generate URLs /// + /// 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 Update2Async( @@ -119,6 +122,7 @@ public partial interface IStorageGcsSaClient string? title = default, string? traceback = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsSaClient.Validate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsSaClient.Validate.g.cs index fa7506e..dd536a2 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsSaClient.Validate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsSaClient.Validate.g.cs @@ -15,11 +15,13 @@ public partial interface IStorageGcsSaClient /// Validate a specific GCS export storage connection set up with SA Impersonation. ///
/// + /// 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 ValidateAsync( global::LabelStudio.GCSSAExportStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Validate GCS SA export storage
@@ -87,6 +89,7 @@ public partial interface IStorageGcsSaClient /// /// Interpret objects as BLOBs and generate URLs /// + /// 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 ValidateAsync( @@ -107,6 +110,7 @@ public partial interface IStorageGcsSaClient string? title = default, string? traceback = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsSaClient.Validate2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsSaClient.Validate2.g.cs index 13b49c6..6554b1a 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsSaClient.Validate2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsSaClient.Validate2.g.cs @@ -15,11 +15,13 @@ public partial interface IStorageGcsSaClient /// Validate a specific GCS import storage connection set up with SA Impersonation. ///
/// + /// 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 Validate2Async( global::LabelStudio.GCSSAImportStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Validate GCS SA import storage
@@ -93,6 +95,7 @@ public partial interface IStorageGcsSaClient /// /// Interpret objects as BLOBs and generate URLs /// + /// 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 Validate2Async( @@ -115,6 +118,7 @@ public partial interface IStorageGcsSaClient string? title = default, string? traceback = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsSaClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsSaClient.g.cs index cb2907e..3d9a4ed 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsSaClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsSaClient.g.cs @@ -33,6 +33,11 @@ public partial interface IStorageGcsSaClient : global::System.IDisposable ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsWifClient.Create.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsWifClient.Create.g.cs index bcac9d6..4bc3fd1 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsWifClient.Create.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsWifClient.Create.g.cs @@ -15,11 +15,13 @@ public partial interface IStorageGcsWifClient /// Create an GCS export storage connection with WIF authentication to store annotations. /// /// + /// 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 CreateAsync( global::LabelStudio.GCSWIFExportStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Create GCS export storage with WIF authentication
@@ -99,6 +101,7 @@ public partial interface IStorageGcsWifClient /// /// Interpret objects as BLOBs and generate URLs /// + /// 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 CreateAsync( @@ -123,6 +126,7 @@ public partial interface IStorageGcsWifClient string? title = default, string? traceback = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsWifClient.Create2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsWifClient.Create2.g.cs index e325230..6f9d470 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsWifClient.Create2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsWifClient.Create2.g.cs @@ -15,11 +15,13 @@ public partial interface IStorageGcsWifClient /// Create GCS import storage with WIF. ///
/// + /// 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 Create2Async( global::LabelStudio.GCSWIFImportStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Create GCS import storage with WIF
@@ -105,6 +107,7 @@ public partial interface IStorageGcsWifClient /// /// Interpret objects as BLOBs and generate URLs /// + /// 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 Create2Async( @@ -131,6 +134,7 @@ public partial interface IStorageGcsWifClient string? title = default, string? traceback = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsWifClient.Delete.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsWifClient.Delete.g.cs index 0dbfe38..447d5aa 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsWifClient.Delete.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsWifClient.Delete.g.cs @@ -15,10 +15,12 @@ public partial interface IStorageGcsWifClient /// Delete a specific GCS export storage connection that was set up with WIF authentication. ///
/// + /// 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 DeleteAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsWifClient.Delete2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsWifClient.Delete2.g.cs index aeb8761..d35238e 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsWifClient.Delete2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsWifClient.Delete2.g.cs @@ -15,10 +15,12 @@ public partial interface IStorageGcsWifClient /// Delete a specific GCS import storage connection that was set up with WIF authentication. /// /// + /// 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 Delete2Async( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsWifClient.Get.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsWifClient.Get.g.cs index 0de5646..ae8ac34 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsWifClient.Get.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsWifClient.Get.g.cs @@ -15,10 +15,12 @@ public partial interface IStorageGcsWifClient /// Get a specific GCS export storage connection that was set up with WIF authentication. /// /// + /// 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 GetAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsWifClient.Get2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsWifClient.Get2.g.cs index fa0b4fe..0bed26a 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsWifClient.Get2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsWifClient.Get2.g.cs @@ -15,10 +15,12 @@ public partial interface IStorageGcsWifClient /// Get a specific GCS import storage connection that was set up with WIF. /// /// + /// 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 Get2Async( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsWifClient.List.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsWifClient.List.g.cs index 943d8de..c5d351c 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsWifClient.List.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsWifClient.List.g.cs @@ -16,11 +16,13 @@ public partial interface IStorageGcsWifClient /// /// /// + /// 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> ListAsync( int project, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsWifClient.List2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsWifClient.List2.g.cs index 6cb0a36..0e4c92c 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsWifClient.List2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsWifClient.List2.g.cs @@ -16,11 +16,13 @@ public partial interface IStorageGcsWifClient /// /// /// + /// 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> List2Async( int project, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsWifClient.Sync.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsWifClient.Sync.g.cs index b2f8b40..c1011f9 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsWifClient.Sync.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsWifClient.Sync.g.cs @@ -15,10 +15,12 @@ public partial interface IStorageGcsWifClient /// Sync tasks from an GCS WIF export 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 SyncAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsWifClient.Sync2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsWifClient.Sync2.g.cs index ed740d1..f14c851 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsWifClient.Sync2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsWifClient.Sync2.g.cs @@ -15,10 +15,12 @@ public partial interface IStorageGcsWifClient /// Sync tasks from an GCS import storage connection that was set up with WIF authentication. /// /// + /// 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 Sync2Async( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsWifClient.Update.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsWifClient.Update.g.cs index 44d48d8..00821b3 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsWifClient.Update.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsWifClient.Update.g.cs @@ -16,12 +16,14 @@ public partial interface IStorageGcsWifClient /// /// /// + /// 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 UpdateAsync( int id, global::LabelStudio.PatchedGCSWIFExportStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Update GCS WIF export storage
@@ -102,6 +104,7 @@ public partial interface IStorageGcsWifClient /// /// Interpret objects as BLOBs and generate URLs /// + /// 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 UpdateAsync( @@ -127,6 +130,7 @@ public partial interface IStorageGcsWifClient string? title = default, string? traceback = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsWifClient.Update2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsWifClient.Update2.g.cs index ea3927f..4a56e26 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsWifClient.Update2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsWifClient.Update2.g.cs @@ -16,12 +16,14 @@ public partial interface IStorageGcsWifClient ///
/// /// + /// 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 Update2Async( int id, global::LabelStudio.PatchedGCSWIFImportStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Update GCS WIF import storage
@@ -108,6 +110,7 @@ public partial interface IStorageGcsWifClient /// /// Interpret objects as BLOBs and generate URLs /// + /// 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 Update2Async( @@ -135,6 +138,7 @@ public partial interface IStorageGcsWifClient string? title = default, string? traceback = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsWifClient.Validate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsWifClient.Validate.g.cs index 588243d..4a6cc41 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsWifClient.Validate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsWifClient.Validate.g.cs @@ -15,11 +15,13 @@ public partial interface IStorageGcsWifClient /// Validate a specific GCS export storage connection that was set up with WIF authentication. ///
/// + /// 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 ValidateAsync( global::LabelStudio.GCSWIFExportStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Validate GCS WIF export storage
@@ -99,6 +101,7 @@ public partial interface IStorageGcsWifClient /// /// Interpret objects as BLOBs and generate URLs /// + /// 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 ValidateAsync( @@ -123,6 +126,7 @@ public partial interface IStorageGcsWifClient string? title = default, string? traceback = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsWifClient.Validate2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsWifClient.Validate2.g.cs index 2f4dcda..8611895 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsWifClient.Validate2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsWifClient.Validate2.g.cs @@ -15,11 +15,13 @@ public partial interface IStorageGcsWifClient /// Validate a specific GCS import storage connection that was set up with WIF authentication. ///
/// + /// 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 Validate2Async( global::LabelStudio.GCSWIFImportStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Validate GCS WIF import storage
@@ -105,6 +107,7 @@ public partial interface IStorageGcsWifClient /// /// Interpret objects as BLOBs and generate URLs /// + /// 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 Validate2Async( @@ -131,6 +134,7 @@ public partial interface IStorageGcsWifClient string? title = default, string? traceback = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsWifClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsWifClient.g.cs index d985dfc..0e16392 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsWifClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageGcsWifClient.g.cs @@ -33,6 +33,11 @@ public partial interface IStorageGcsWifClient : global::System.IDisposable ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageLocalClient.Create.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageLocalClient.Create.g.cs index 2c2c653..f858071 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageLocalClient.Create.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageLocalClient.Create.g.cs @@ -9,11 +9,13 @@ public partial interface IStorageLocalClient /// Create a new local file export storage connection to store annotations. /// /// + /// 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 CreateAsync( global::LabelStudio.ApiStoragesExportLocalfilesCreateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Create export storage
@@ -38,6 +40,7 @@ public partial interface IStorageLocalClient /// Interpret objects as BLOBs and generate URLs. For example, if your directory contains images, you can use this option to generate URLs for these images. If set to False, it will read the content of the file and load it into Label Studio.
/// 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 CreateAsync( @@ -47,6 +50,7 @@ public partial interface IStorageLocalClient string? regexFilter = default, string? title = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageLocalClient.Create2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageLocalClient.Create2.g.cs index dbb260b..293a70d 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageLocalClient.Create2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageLocalClient.Create2.g.cs @@ -9,11 +9,13 @@ public partial interface IStorageLocalClient /// Create a new local file import storage connection. ///
/// + /// 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 Create2Async( global::LabelStudio.ApiStoragesLocalfilesCreateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Create import storage
@@ -38,6 +40,7 @@ public partial interface IStorageLocalClient /// Interpret objects as BLOBs and generate URLs. For example, if your directory contains images, you can use this option to generate URLs for these images. If set to False, it will read the content of the file and load it into Label Studio.
/// 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 Create2Async( @@ -47,6 +50,7 @@ public partial interface IStorageLocalClient string? regexFilter = default, string? title = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageLocalClient.Delete.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageLocalClient.Delete.g.cs index 24857ee..8bc54eb 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageLocalClient.Delete.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageLocalClient.Delete.g.cs @@ -9,10 +9,12 @@ public partial interface IStorageLocalClient /// Delete a specific local file export storage connection. ///
/// + /// 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 DeleteAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageLocalClient.Delete2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageLocalClient.Delete2.g.cs index 2e70d7c..a9b3afb 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageLocalClient.Delete2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageLocalClient.Delete2.g.cs @@ -9,10 +9,12 @@ public partial interface IStorageLocalClient /// Delete a specific local file import storage connection. /// /// + /// 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 Delete2Async( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageLocalClient.Get.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageLocalClient.Get.g.cs index 9d37668..9a0617e 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageLocalClient.Get.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageLocalClient.Get.g.cs @@ -9,10 +9,12 @@ public partial interface IStorageLocalClient /// Get a specific local file export storage connection. /// /// + /// 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 GetAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageLocalClient.Get2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageLocalClient.Get2.g.cs index 4c4db02..cd4b98f 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageLocalClient.Get2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageLocalClient.Get2.g.cs @@ -9,10 +9,12 @@ public partial interface IStorageLocalClient /// Get a specific local file import storage connection. /// /// + /// 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 Get2Async( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageLocalClient.List.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageLocalClient.List.g.cs index b03cd42..d83974f 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageLocalClient.List.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageLocalClient.List.g.cs @@ -10,11 +10,13 @@ public partial interface IStorageLocalClient /// /// /// + /// 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> ListAsync( int project, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageLocalClient.List2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageLocalClient.List2.g.cs index 45fb191..af2ddef 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageLocalClient.List2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageLocalClient.List2.g.cs @@ -10,11 +10,13 @@ public partial interface IStorageLocalClient /// /// /// + /// 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> List2Async( int project, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageLocalClient.Sync.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageLocalClient.Sync.g.cs index 67fc3fe..c09462c 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageLocalClient.Sync.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageLocalClient.Sync.g.cs @@ -9,10 +9,12 @@ public partial interface IStorageLocalClient /// Sync tasks from a local file export storage connection. /// /// + /// 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 SyncAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageLocalClient.Sync2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageLocalClient.Sync2.g.cs index 35f4fa9..113fc5e 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageLocalClient.Sync2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageLocalClient.Sync2.g.cs @@ -9,10 +9,12 @@ public partial interface IStorageLocalClient /// Sync tasks from a local file import storage connection. /// /// + /// 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 Sync2Async( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageLocalClient.Update.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageLocalClient.Update.g.cs index ea2d310..efe892e 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageLocalClient.Update.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageLocalClient.Update.g.cs @@ -10,12 +10,14 @@ public partial interface IStorageLocalClient /// /// /// + /// 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 UpdateAsync( int id, global::LabelStudio.ApiStoragesExportLocalfilesPartialUpdateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Update export storage
@@ -41,6 +43,7 @@ public partial interface IStorageLocalClient /// Interpret objects as BLOBs and generate URLs. For example, if your directory contains images, you can use this option to generate URLs for these images. If set to False, it will read the content of the file and load it into Label Studio.
/// 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 UpdateAsync( @@ -51,6 +54,7 @@ public partial interface IStorageLocalClient string? regexFilter = default, string? title = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageLocalClient.Update2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageLocalClient.Update2.g.cs index b749746..7de6205 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageLocalClient.Update2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageLocalClient.Update2.g.cs @@ -10,12 +10,14 @@ public partial interface IStorageLocalClient ///
/// /// + /// 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 Update2Async( int id, global::LabelStudio.ApiStoragesLocalfilesPartialUpdateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Update import storage
@@ -41,6 +43,7 @@ public partial interface IStorageLocalClient /// Interpret objects as BLOBs and generate URLs. For example, if your directory contains images, you can use this option to generate URLs for these images. If set to False, it will read the content of the file and load it into Label Studio.
/// 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 Update2Async( @@ -51,6 +54,7 @@ public partial interface IStorageLocalClient string? regexFilter = default, string? title = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageLocalClient.Validate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageLocalClient.Validate.g.cs index 48b2803..6b883c6 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageLocalClient.Validate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageLocalClient.Validate.g.cs @@ -9,11 +9,13 @@ public partial interface IStorageLocalClient /// Validate a specific local file export storage connection. ///
/// + /// 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 ValidateAsync( global::LabelStudio.ApiStoragesExportLocalfilesValidateCreateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Validate export storage
@@ -41,6 +43,7 @@ public partial interface IStorageLocalClient /// Interpret objects as BLOBs and generate URLs. For example, if your directory contains images, you can use this option to generate URLs for these images. If set to False, it will read the content of the file and load it into Label Studio.
/// 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 ValidateAsync( @@ -51,6 +54,7 @@ public partial interface IStorageLocalClient string? regexFilter = default, string? title = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageLocalClient.Validate2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageLocalClient.Validate2.g.cs index 7a5a739..3ddce3b 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageLocalClient.Validate2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageLocalClient.Validate2.g.cs @@ -9,11 +9,13 @@ public partial interface IStorageLocalClient /// Validate a specific local file import storage connection. ///
/// + /// 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 Validate2Async( global::LabelStudio.ApiStoragesLocalfilesValidateCreateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Validate import storage
@@ -41,6 +43,7 @@ public partial interface IStorageLocalClient /// Interpret objects as BLOBs and generate URLs. For example, if your directory contains images, you can use this option to generate URLs for these images. If set to False, it will read the content of the file and load it into Label Studio.
/// 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 Validate2Async( @@ -51,6 +54,7 @@ public partial interface IStorageLocalClient string? regexFilter = default, string? title = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageLocalClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageLocalClient.g.cs index aa6be8e..613f0ad 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageLocalClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageLocalClient.g.cs @@ -33,6 +33,11 @@ public partial interface IStorageLocalClient : global::System.IDisposable ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageRedisClient.Create.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageRedisClient.Create.g.cs index 3c6e09b..b5c8731 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageRedisClient.Create.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageRedisClient.Create.g.cs @@ -9,11 +9,13 @@ public partial interface IStorageRedisClient /// Create a new Redis export storage connection to store annotations. /// /// + /// 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 CreateAsync( global::LabelStudio.ApiStoragesExportRedisCreateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Create export storage
@@ -47,6 +49,7 @@ public partial interface IStorageRedisClient /// /// Storage title /// + /// 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 CreateAsync( @@ -59,6 +62,7 @@ public partial interface IStorageRedisClient string? port = default, int? project = default, string? title = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageRedisClient.Create2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageRedisClient.Create2.g.cs index afc03b1..cfd4873 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageRedisClient.Create2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageRedisClient.Create2.g.cs @@ -9,11 +9,13 @@ public partial interface IStorageRedisClient /// Create a new Redis import storage connection. ///
/// + /// 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 Create2Async( global::LabelStudio.ApiStoragesRedisCreateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Create import storage
@@ -47,6 +49,7 @@ public partial interface IStorageRedisClient /// Interpret objects as BLOBs and generate URLs. For example, if your bucket contains images, you can use this option to generate URLs for these images. If set to False, it will read the content of the file and load it into Label Studio.
/// 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 Create2Async( @@ -59,6 +62,7 @@ public partial interface IStorageRedisClient string? regexFilter = default, string? title = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageRedisClient.Delete.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageRedisClient.Delete.g.cs index 806e6c7..be6c7f4 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageRedisClient.Delete.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageRedisClient.Delete.g.cs @@ -9,10 +9,12 @@ public partial interface IStorageRedisClient /// Delete a specific Redis export storage connection. ///
/// + /// 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 DeleteAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageRedisClient.Delete2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageRedisClient.Delete2.g.cs index 544b098..69fed44 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageRedisClient.Delete2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageRedisClient.Delete2.g.cs @@ -9,10 +9,12 @@ public partial interface IStorageRedisClient /// Delete a specific Redis import storage connection. /// /// + /// 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 Delete2Async( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageRedisClient.Get.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageRedisClient.Get.g.cs index 49e5763..e64e9e3 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageRedisClient.Get.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageRedisClient.Get.g.cs @@ -9,10 +9,12 @@ public partial interface IStorageRedisClient /// Get a specific Redis export storage connection. /// /// + /// 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 GetAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageRedisClient.Get2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageRedisClient.Get2.g.cs index 25c7f7c..8d4ac11 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageRedisClient.Get2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageRedisClient.Get2.g.cs @@ -9,10 +9,12 @@ public partial interface IStorageRedisClient /// Get a specific Redis import storage connection. /// /// + /// 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 Get2Async( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageRedisClient.List.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageRedisClient.List.g.cs index 0bd5327..9a22797 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageRedisClient.List.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageRedisClient.List.g.cs @@ -10,11 +10,13 @@ public partial interface IStorageRedisClient /// /// /// + /// 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> ListAsync( int project, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageRedisClient.List2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageRedisClient.List2.g.cs index f1035f0..e65c05c 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageRedisClient.List2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageRedisClient.List2.g.cs @@ -10,11 +10,13 @@ public partial interface IStorageRedisClient /// /// /// + /// 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> List2Async( int project, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageRedisClient.Sync.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageRedisClient.Sync.g.cs index 042f252..73a0074 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageRedisClient.Sync.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageRedisClient.Sync.g.cs @@ -9,10 +9,12 @@ public partial interface IStorageRedisClient /// Sync tasks from a Redis export storage connection. /// /// + /// 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 SyncAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageRedisClient.Sync2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageRedisClient.Sync2.g.cs index fd3dfed..54ddf8d 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageRedisClient.Sync2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageRedisClient.Sync2.g.cs @@ -9,10 +9,12 @@ public partial interface IStorageRedisClient /// Sync tasks from a Redis import storage connection. /// /// + /// 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 Sync2Async( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageRedisClient.Update.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageRedisClient.Update.g.cs index 5db4020..4aa71da 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageRedisClient.Update.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageRedisClient.Update.g.cs @@ -10,12 +10,14 @@ public partial interface IStorageRedisClient /// /// /// + /// 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 UpdateAsync( int id, global::LabelStudio.ApiStoragesExportRedisPartialUpdateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Update export storage
@@ -50,6 +52,7 @@ public partial interface IStorageRedisClient /// /// Storage title /// + /// 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 UpdateAsync( @@ -63,6 +66,7 @@ public partial interface IStorageRedisClient string? port = default, int? project = default, string? title = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageRedisClient.Update2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageRedisClient.Update2.g.cs index b9887d5..07ed607 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageRedisClient.Update2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageRedisClient.Update2.g.cs @@ -10,12 +10,14 @@ public partial interface IStorageRedisClient ///
/// /// + /// 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 Update2Async( int id, global::LabelStudio.ApiStoragesRedisPartialUpdateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Update import storage
@@ -50,6 +52,7 @@ public partial interface IStorageRedisClient /// Interpret objects as BLOBs and generate URLs. For example, if your bucket contains images, you can use this option to generate URLs for these images. If set to False, it will read the content of the file and load it into Label Studio.
/// 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 Update2Async( @@ -63,6 +66,7 @@ public partial interface IStorageRedisClient string? regexFilter = default, string? title = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageRedisClient.Validate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageRedisClient.Validate.g.cs index 6175858..8e84159 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageRedisClient.Validate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageRedisClient.Validate.g.cs @@ -9,11 +9,13 @@ public partial interface IStorageRedisClient /// Validate a specific Redis export storage connection. ///
/// + /// 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 ValidateAsync( global::LabelStudio.ApiStoragesExportRedisValidateCreateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Validate export storage
@@ -50,6 +52,7 @@ public partial interface IStorageRedisClient /// /// Storage title /// + /// 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 ValidateAsync( @@ -63,6 +66,7 @@ public partial interface IStorageRedisClient string? port = default, int? project = default, string? title = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageRedisClient.Validate2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageRedisClient.Validate2.g.cs index f5b2aab..054defd 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageRedisClient.Validate2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageRedisClient.Validate2.g.cs @@ -9,11 +9,13 @@ public partial interface IStorageRedisClient /// Validate a specific Redis import storage connection. ///
/// + /// 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 Validate2Async( global::LabelStudio.ApiStoragesRedisValidateCreateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Validate import storage
@@ -50,6 +52,7 @@ public partial interface IStorageRedisClient /// Interpret objects as BLOBs and generate URLs. For example, if your bucket contains images, you can use this option to generate URLs for these images. If set to False, it will read the content of the file and load it into Label Studio.
/// 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 Validate2Async( @@ -63,6 +66,7 @@ public partial interface IStorageRedisClient string? regexFilter = default, string? title = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageRedisClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageRedisClient.g.cs index 23bc372..742746d 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageRedisClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageRedisClient.g.cs @@ -33,6 +33,11 @@ public partial interface IStorageRedisClient : global::System.IDisposable ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3Client.Create.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3Client.Create.g.cs index 941c3af..5380b11 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3Client.Create.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3Client.Create.g.cs @@ -9,11 +9,13 @@ public partial interface IStorageS3Client /// Create a new S3 export storage connection to store annotations. /// /// + /// 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 CreateAsync( global::LabelStudio.ApiStoragesExportS3CreateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Create export storage
@@ -56,6 +58,7 @@ public partial interface IStorageS3Client /// /// Storage title /// + /// 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 CreateAsync( @@ -71,6 +74,7 @@ public partial interface IStorageS3Client string? regionName = default, string? s3Endpoint = default, string? title = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3Client.Create2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3Client.Create2.g.cs index 06be0c3..b78f2ba 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3Client.Create2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3Client.Create2.g.cs @@ -9,11 +9,13 @@ public partial interface IStorageS3Client /// Create new S3 import 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 Create2Async( global::LabelStudio.ApiStoragesS3CreateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Create new S3 storage
@@ -70,6 +72,7 @@ public partial interface IStorageS3Client /// Interpret objects as BLOBs and generate URLs. For example, if your bucket contains images, you can use this option to generate URLs for these images. If set to False, it will read the content of the file and load it into Label Studio.
/// 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 Create2Async( @@ -89,6 +92,7 @@ public partial interface IStorageS3Client string? s3Endpoint = default, string? title = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3Client.Delete.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3Client.Delete.g.cs index 9b24010..71b6543 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3Client.Delete.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3Client.Delete.g.cs @@ -9,10 +9,12 @@ public partial interface IStorageS3Client /// Delete a specific S3 export storage connection. ///
/// + /// 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 DeleteAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3Client.Delete2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3Client.Delete2.g.cs index f1b21b9..0f44231 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3Client.Delete2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3Client.Delete2.g.cs @@ -9,10 +9,12 @@ public partial interface IStorageS3Client /// Delete a specific S3 import storage connection. /// /// + /// 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 Delete2Async( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3Client.Get.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3Client.Get.g.cs index 162def6..be5eae1 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3Client.Get.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3Client.Get.g.cs @@ -9,10 +9,12 @@ public partial interface IStorageS3Client /// Get a specific S3 export storage connection. /// /// + /// 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 GetAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3Client.Get2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3Client.Get2.g.cs index afc18c9..72b3ba5 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3Client.Get2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3Client.Get2.g.cs @@ -9,10 +9,12 @@ public partial interface IStorageS3Client /// Get a specific S3 import storage connection. /// /// + /// 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 Get2Async( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3Client.List.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3Client.List.g.cs index beaadeb..eb891df 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3Client.List.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3Client.List.g.cs @@ -10,11 +10,13 @@ public partial interface IStorageS3Client /// /// /// + /// 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> ListAsync( int project, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3Client.List2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3Client.List2.g.cs index 1aa8adb..c189010 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3Client.List2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3Client.List2.g.cs @@ -10,11 +10,13 @@ public partial interface IStorageS3Client /// /// /// + /// 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> List2Async( int project, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3Client.Sync.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3Client.Sync.g.cs index 156ab6d..f7a976f 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3Client.Sync.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3Client.Sync.g.cs @@ -9,10 +9,12 @@ public partial interface IStorageS3Client /// Sync tasks from an S3 export storage connection. /// /// + /// 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 SyncAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3Client.Sync2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3Client.Sync2.g.cs index 9874a17..3d3a836 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3Client.Sync2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3Client.Sync2.g.cs @@ -9,10 +9,12 @@ public partial interface IStorageS3Client /// Sync tasks from an S3 import storage connection. /// /// + /// 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 Sync2Async( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3Client.Update.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3Client.Update.g.cs index 42d3148..603e604 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3Client.Update.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3Client.Update.g.cs @@ -10,12 +10,14 @@ public partial interface IStorageS3Client /// /// /// + /// 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 UpdateAsync( int id, global::LabelStudio.ApiStoragesExportS3PartialUpdateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Update export storage
@@ -59,6 +61,7 @@ public partial interface IStorageS3Client /// /// Storage title /// + /// 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 UpdateAsync( @@ -75,6 +78,7 @@ public partial interface IStorageS3Client string? regionName = default, string? s3Endpoint = default, string? title = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3Client.Update2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3Client.Update2.g.cs index 160c4f6..ea5263d 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3Client.Update2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3Client.Update2.g.cs @@ -10,12 +10,14 @@ public partial interface IStorageS3Client ///
/// /// + /// 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 Update2Async( int id, global::LabelStudio.ApiStoragesS3PartialUpdateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Update import storage
@@ -73,6 +75,7 @@ public partial interface IStorageS3Client /// Interpret objects as BLOBs and generate URLs. For example, if your bucket contains images, you can use this option to generate URLs for these images. If set to False, it will read the content of the file and load it into Label Studio.
/// 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 Update2Async( @@ -93,6 +96,7 @@ public partial interface IStorageS3Client string? s3Endpoint = default, string? title = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3Client.Validate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3Client.Validate.g.cs index 732f375..fa0b19a 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3Client.Validate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3Client.Validate.g.cs @@ -9,11 +9,13 @@ public partial interface IStorageS3Client /// Validate a specific S3 export storage connection. ///
/// + /// 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 ValidateAsync( global::LabelStudio.ApiStoragesExportS3ValidateCreateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Validate export storage
@@ -59,6 +61,7 @@ public partial interface IStorageS3Client /// /// Storage title /// + /// 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 ValidateAsync( @@ -75,6 +78,7 @@ public partial interface IStorageS3Client string? regionName = default, string? s3Endpoint = default, string? title = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3Client.Validate2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3Client.Validate2.g.cs index 5d0d74b..6396123 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3Client.Validate2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3Client.Validate2.g.cs @@ -9,11 +9,13 @@ public partial interface IStorageS3Client /// Validate a specific S3 import storage connection. ///
/// + /// 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 Validate2Async( global::LabelStudio.ApiStoragesS3ValidateCreateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Validate import storage
@@ -73,6 +75,7 @@ public partial interface IStorageS3Client /// Interpret objects as BLOBs and generate URLs. For example, if your bucket contains images, you can use this option to generate URLs for these images. If set to False, it will read the content of the file and load it into Label Studio.
/// 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 Validate2Async( @@ -93,6 +96,7 @@ public partial interface IStorageS3Client string? s3Endpoint = default, string? title = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3Client.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3Client.g.cs index 9ed5302..a261848 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3Client.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3Client.g.cs @@ -33,6 +33,11 @@ public partial interface IStorageS3Client : global::System.IDisposable ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3RolesClient.Create.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3RolesClient.Create.g.cs index ffb9cb2..49dcffc 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3RolesClient.Create.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3RolesClient.Create.g.cs @@ -15,11 +15,13 @@ public partial interface IStorageS3RolesClient /// Create an S3 export storage connection with IAM role access to store annotations. /// /// + /// 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 CreateAsync( global::LabelStudio.LseS3ExportStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Create export storage
@@ -106,6 +108,7 @@ public partial interface IStorageS3RolesClient /// /// Interpret objects as BLOBs and generate URLs /// + /// 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 CreateAsync( @@ -133,6 +136,7 @@ public partial interface IStorageS3RolesClient string? title = default, string? traceback = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3RolesClient.Create2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3RolesClient.Create2.g.cs index 5cf1b53..ae2ef67 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3RolesClient.Create2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3RolesClient.Create2.g.cs @@ -15,11 +15,13 @@ public partial interface IStorageS3RolesClient /// Create S3 import storage with IAM role access. ///
/// + /// 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 Create2Async( global::LabelStudio.LseS3ImportStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Create import storage
@@ -112,6 +114,7 @@ public partial interface IStorageS3RolesClient /// /// Interpret objects as BLOBs and generate URLs /// + /// 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 Create2Async( @@ -141,6 +144,7 @@ public partial interface IStorageS3RolesClient string? title = default, string? traceback = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3RolesClient.Delete.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3RolesClient.Delete.g.cs index f603a33..c60033b 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3RolesClient.Delete.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3RolesClient.Delete.g.cs @@ -15,10 +15,12 @@ public partial interface IStorageS3RolesClient /// Delete a specific S3 export storage connection that was set up with IAM role access. ///
/// + /// 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 DeleteAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3RolesClient.Delete2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3RolesClient.Delete2.g.cs index d34c01c..6b0bc55 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3RolesClient.Delete2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3RolesClient.Delete2.g.cs @@ -15,10 +15,12 @@ public partial interface IStorageS3RolesClient /// Delete a specific S3 import storage connection that was set up with IAM role access. /// /// + /// 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 Delete2Async( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3RolesClient.Get.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3RolesClient.Get.g.cs index a54a8a8..be8fbf3 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3RolesClient.Get.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3RolesClient.Get.g.cs @@ -15,10 +15,12 @@ public partial interface IStorageS3RolesClient /// Get a specific S3 export storage connection that was set up with IAM role access. /// /// + /// 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 GetAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3RolesClient.Get2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3RolesClient.Get2.g.cs index 5cfab53..e8a38df 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3RolesClient.Get2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3RolesClient.Get2.g.cs @@ -15,10 +15,12 @@ public partial interface IStorageS3RolesClient /// Get a specific S3 import storage connection that was set up with IAM role access. /// /// + /// 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 Get2Async( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3RolesClient.List.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3RolesClient.List.g.cs index 6b26ffb..ce9e878 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3RolesClient.List.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3RolesClient.List.g.cs @@ -16,11 +16,13 @@ public partial interface IStorageS3RolesClient /// /// /// + /// 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> ListAsync( int project, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3RolesClient.List2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3RolesClient.List2.g.cs index 351552b..b9c0f69 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3RolesClient.List2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3RolesClient.List2.g.cs @@ -16,11 +16,13 @@ public partial interface IStorageS3RolesClient /// /// /// + /// 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> List2Async( int project, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3RolesClient.Sync.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3RolesClient.Sync.g.cs index 248c0aa..1319f89 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3RolesClient.Sync.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3RolesClient.Sync.g.cs @@ -15,10 +15,12 @@ public partial interface IStorageS3RolesClient /// Sync tasks from an S3 export 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 SyncAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3RolesClient.Sync2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3RolesClient.Sync2.g.cs index 03ce430..acb8550 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3RolesClient.Sync2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3RolesClient.Sync2.g.cs @@ -15,10 +15,12 @@ public partial interface IStorageS3RolesClient /// Sync tasks from an S3 import storage connection that was set up with IAM role access. /// /// + /// 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 Sync2Async( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3RolesClient.Update.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3RolesClient.Update.g.cs index 2059e08..bc5027d 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3RolesClient.Update.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3RolesClient.Update.g.cs @@ -16,12 +16,14 @@ public partial interface IStorageS3RolesClient /// /// /// + /// 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 UpdateAsync( int id, global::LabelStudio.PatchedLseS3ExportStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Update export storage
@@ -109,6 +111,7 @@ public partial interface IStorageS3RolesClient /// /// Interpret objects as BLOBs and generate URLs /// + /// 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 UpdateAsync( @@ -137,6 +140,7 @@ public partial interface IStorageS3RolesClient string? title = default, string? traceback = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3RolesClient.Update2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3RolesClient.Update2.g.cs index dece790..32d63e1 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3RolesClient.Update2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3RolesClient.Update2.g.cs @@ -16,12 +16,14 @@ public partial interface IStorageS3RolesClient ///
/// /// + /// 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 Update2Async( int id, global::LabelStudio.PatchedLseS3ImportStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Update import storage
@@ -115,6 +117,7 @@ public partial interface IStorageS3RolesClient /// /// Interpret objects as BLOBs and generate URLs /// + /// 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 Update2Async( @@ -145,6 +148,7 @@ public partial interface IStorageS3RolesClient string? title = default, string? traceback = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3RolesClient.Validate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3RolesClient.Validate.g.cs index ec480b9..30c9b81 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3RolesClient.Validate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3RolesClient.Validate.g.cs @@ -15,11 +15,13 @@ public partial interface IStorageS3RolesClient /// Validate a specific S3 export storage connection that was set up with IAM role access. ///
/// + /// 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 ValidateAsync( global::LabelStudio.LseS3ExportStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Validate export storage
@@ -106,6 +108,7 @@ public partial interface IStorageS3RolesClient /// /// Interpret objects as BLOBs and generate URLs /// + /// 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 ValidateAsync( @@ -133,6 +136,7 @@ public partial interface IStorageS3RolesClient string? title = default, string? traceback = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3RolesClient.Validate2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3RolesClient.Validate2.g.cs index d424676..fa7bef3 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3RolesClient.Validate2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3RolesClient.Validate2.g.cs @@ -15,11 +15,13 @@ public partial interface IStorageS3RolesClient /// Validate a specific S3 import storage connection that was set up with IAM role access. ///
/// + /// 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 Validate2Async( global::LabelStudio.LseS3ImportStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Validate import storage
@@ -112,6 +114,7 @@ public partial interface IStorageS3RolesClient /// /// Interpret objects as BLOBs and generate URLs /// + /// 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 Validate2Async( @@ -141,6 +144,7 @@ public partial interface IStorageS3RolesClient string? title = default, string? traceback = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3RolesClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3RolesClient.g.cs index a363531..0b42f52 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3RolesClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IStorageS3RolesClient.g.cs @@ -33,6 +33,11 @@ public partial interface IStorageS3RolesClient : global::System.IDisposable ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ITasks2Client.Create.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ITasks2Client.Create.g.cs index af9a84a..810d4f9 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ITasks2Client.Create.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ITasks2Client.Create.g.cs @@ -9,11 +9,13 @@ public partial interface ITasks2Client /// Create a new task /// /// + /// 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 CreateAsync( global::LabelStudio.LseTaskRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Create a new task
@@ -67,6 +69,7 @@ public partial interface ITasks2Client /// /// Last annotator or reviewer who updated this task /// + /// 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 CreateAsync( @@ -86,6 +89,7 @@ public partial interface ITasks2Client int? totalPredictions = default, int? unresolvedCommentCount = default, int? updatedBy = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ITasks2Client.CreateEvent.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ITasks2Client.CreateEvent.g.cs index bfa38ee..c20b630 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ITasks2Client.CreateEvent.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ITasks2Client.CreateEvent.g.cs @@ -47,12 +47,14 @@ public partial interface ITasks2Client ///
/// /// + /// 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 CreateEventAsync( int id, global::LabelStudio.TaskEventRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Create task event
@@ -114,6 +116,7 @@ public partial interface ITasks2Client /// /// Review ID associated with this event /// + /// 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 CreateEventAsync( @@ -124,6 +127,7 @@ public partial interface ITasks2Client int? annotationDraftId = default, object? meta = default, int? review = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ITasks2Client.CreateManyStatus.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ITasks2Client.CreateManyStatus.g.cs index 6baf72e..3a17fba 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ITasks2Client.CreateManyStatus.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ITasks2Client.CreateManyStatus.g.cs @@ -19,11 +19,13 @@ public partial interface ITasks2Client ///
/// /// + /// 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 CreateManyStatusAsync( int id, int importPk, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ITasks2Client.Delete2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ITasks2Client.Delete2.g.cs index 8a8779f..5a848ba 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ITasks2Client.Delete2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ITasks2Client.Delete2.g.cs @@ -9,10 +9,12 @@ public partial interface ITasks2Client /// Delete a task in Label Studio. This action cannot be undone! /// /// + /// 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 Delete2Async( string id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ITasks2Client.DeleteAllTasks.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ITasks2Client.DeleteAllTasks.g.cs index d61a85d..b15197b 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ITasks2Client.DeleteAllTasks.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ITasks2Client.DeleteAllTasks.g.cs @@ -9,10 +9,12 @@ public partial interface ITasks2Client /// Delete all tasks from a specific project. /// /// + /// 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 DeleteAllTasksAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ITasks2Client.Get.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ITasks2Client.Get.g.cs index b2d5e2a..a51bcea 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ITasks2Client.Get.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ITasks2Client.Get.g.cs @@ -9,10 +9,12 @@ public partial interface ITasks2Client /// Get task data, metadata, annotations and other attributes for a specific labeling task by task ID. /// /// + /// 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 GetAsync( string id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ITasks2Client.List2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ITasks2Client.List2.g.cs index c8f160c..7964dad 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ITasks2Client.List2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ITasks2Client.List2.g.cs @@ -22,6 +22,7 @@ public partial interface ITasks2Client /// /// /// + /// 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 List2Async( @@ -36,6 +37,7 @@ public partial interface ITasks2Client bool? review = default, string? selectedItems = default, int? view = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ITasks2Client.Update2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ITasks2Client.Update2.g.cs index 70641bc..febf079 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ITasks2Client.Update2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ITasks2Client.Update2.g.cs @@ -10,12 +10,14 @@ public partial interface ITasks2Client /// /// /// + /// 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 Update2Async( string id, global::LabelStudio.PatchedLseTaskRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Update task
@@ -64,6 +66,7 @@ public partial interface ITasks2Client /// /// Number of unresolved comments in the task including all annotations /// + /// 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 Update2Async( @@ -90,6 +93,7 @@ public partial interface ITasks2Client int? totalAnnotations = default, int? totalPredictions = default, int? unresolvedCommentCount = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ITasks2Client.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ITasks2Client.g.cs index ebe5287..9fb19f5 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ITasks2Client.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ITasks2Client.g.cs @@ -33,6 +33,11 @@ public partial interface ITasks2Client : global::System.IDisposable ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ITasksClient.ApiTasksAgreementRetrieve.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ITasksClient.ApiTasksAgreementRetrieve.g.cs index 78663fe..49779a4 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ITasksClient.ApiTasksAgreementRetrieve.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ITasksClient.ApiTasksAgreementRetrieve.g.cs @@ -9,10 +9,12 @@ public partial interface ITasksClient /// Get aggregated label distribution across all annotations for a task. Returns counts of each label value grouped by control tag. This is an efficient endpoint that avoids N+1 queries. /// /// + /// 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 ApiTasksAgreementRetrieveAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ITasksClient.Assign.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ITasksClient.Assign.g.cs index 1be6afc..80ebad1 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ITasksClient.Assign.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ITasksClient.Assign.g.cs @@ -17,6 +17,7 @@ public partial interface ITasksClient /// /// /// + /// 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 AssignAsync( @@ -24,6 +25,7 @@ public partial interface ITasksClient int taskPk, global::LabelStudio.ApiProjectsTasksAssigneesCreate2Request request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Create task assignee
@@ -43,6 +45,7 @@ public partial interface ITasksClient /// /// List of user IDs to assign /// + /// 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 AssignAsync( @@ -50,6 +53,7 @@ public partial interface ITasksClient int taskPk, global::LabelStudio.ApiProjectsTasksAssigneesCreate2RequestType type, global::System.Collections.Generic.IList users, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ITasksClient.BulkAssign.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ITasksClient.BulkAssign.g.cs index b8b7c5d..0868050 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ITasksClient.BulkAssign.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ITasksClient.BulkAssign.g.cs @@ -16,12 +16,14 @@ public partial interface ITasksClient ///
/// /// + /// 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 BulkAssignAsync( int id, global::LabelStudio.ApiProjectsTasksAssigneesCreateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Bulk assign users to tasks
@@ -46,6 +48,7 @@ public partial interface ITasksClient /// /// List of user IDs to assign /// + /// 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 BulkAssignAsync( @@ -54,6 +57,7 @@ public partial interface ITasksClient global::LabelStudio.ApiProjectsTasksAssigneesCreateRequestType type, global::System.Collections.Generic.IList users, global::LabelStudio.ApiProjectsTasksAssigneesCreateRequestFilters? filters = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ITasksClient.Delete.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ITasksClient.Delete.g.cs index 143435d..e5f247a 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ITasksClient.Delete.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ITasksClient.Delete.g.cs @@ -18,6 +18,7 @@ public partial interface ITasksClient /// /// /// + /// 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 DeleteAsync( @@ -25,6 +26,7 @@ public partial interface ITasksClient int taskPk, global::LabelStudio.ApiProjectsTasksAssigneesDestroyType? type = default, string? users = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ITasksClient.List.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ITasksClient.List.g.cs index 524ccc3..2dc6933 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ITasksClient.List.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ITasksClient.List.g.cs @@ -16,11 +16,13 @@ public partial interface ITasksClient ///
/// /// + /// 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> ListAsync( int id, int taskPk, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ITasksClient.Update.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ITasksClient.Update.g.cs index f6cfc03..5bc1398 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ITasksClient.Update.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ITasksClient.Update.g.cs @@ -17,6 +17,7 @@ public partial interface ITasksClient /// /// /// + /// 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 UpdateAsync( @@ -24,6 +25,7 @@ public partial interface ITasksClient int taskPk, global::LabelStudio.ApiProjectsTasksAssigneesPartialUpdateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Update task assignee
@@ -43,6 +45,7 @@ public partial interface ITasksClient /// /// List of user IDs to assign /// + /// 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 UpdateAsync( @@ -50,6 +53,7 @@ public partial interface ITasksClient int taskPk, global::LabelStudio.ApiProjectsTasksAssigneesPartialUpdateRequestType type, global::System.Collections.Generic.IList users, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ITasksClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ITasksClient.g.cs index 77879d8..3e8bec7 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ITasksClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ITasksClient.g.cs @@ -33,6 +33,11 @@ public partial interface ITasksClient : global::System.IDisposable ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ITokensClient.Blacklist.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ITokensClient.Blacklist.g.cs index d18c847..f0d9121 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ITokensClient.Blacklist.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ITokensClient.Blacklist.g.cs @@ -9,11 +9,13 @@ public partial interface ITokensClient /// Adds a JWT refresh token to the blacklist, preventing it from being used to obtain new access tokens. /// /// + /// 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 BlacklistAsync( global::LabelStudio.LSAPITokenBlacklistRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Blacklist a JWT refresh token
@@ -22,10 +24,12 @@ public partial interface ITokensClient /// /// Included only in requests /// + /// 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 BlacklistAsync( string refresh, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ITokensClient.Create.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ITokensClient.Create.g.cs index 163ef1e..02be928 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ITokensClient.Create.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ITokensClient.Create.g.cs @@ -8,9 +8,11 @@ public partial interface ITokensClient /// Create API token
/// Create a new API token for the current user. ///
+ /// 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 CreateAsync( + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ITokensClient.List.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ITokensClient.List.g.cs index 4ef3bde..ef67075 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ITokensClient.List.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ITokensClient.List.g.cs @@ -9,10 +9,12 @@ public partial interface ITokensClient /// List all API tokens for the current user. /// /// + /// 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> ListAsync( string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ITokensClient.Refresh.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ITokensClient.Refresh.g.cs index 1c846d6..a76eb61 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ITokensClient.Refresh.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ITokensClient.Refresh.g.cs @@ -9,11 +9,13 @@ public partial interface ITokensClient /// Get a new access token, using a refresh token. /// /// + /// 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 RefreshAsync( global::LabelStudio.TokenRefreshRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Refresh JWT token
@@ -22,10 +24,12 @@ public partial interface ITokensClient /// /// Included only in requests /// + /// 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 RefreshAsync( string refresh, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ITokensClient.Rotate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ITokensClient.Rotate.g.cs index a27e1d7..e5ac2c0 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ITokensClient.Rotate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ITokensClient.Rotate.g.cs @@ -9,21 +9,25 @@ public partial interface ITokensClient /// Creates a new JWT refresh token and blacklists the current one. ///
/// + /// 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 RotateAsync( global::LabelStudio.LSAPITokenRotateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Rotate JWT refresh token
/// Creates a new JWT refresh token and blacklists the current one. ///
/// + /// 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 RotateAsync( string refresh, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ITokensClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ITokensClient.g.cs index a53d73d..dc9e0e7 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ITokensClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ITokensClient.g.cs @@ -33,6 +33,11 @@ public partial interface ITokensClient : global::System.IDisposable /// public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IUsersClient.Create.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IUsersClient.Create.g.cs index 6034ea2..52f6585 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IUsersClient.Create.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IUsersClient.Create.g.cs @@ -9,11 +9,13 @@ public partial interface IUsersClient /// Create a user in Label Studio. /// /// + /// 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 CreateAsync( global::LabelStudio.ApiUsersCreateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Create new user
@@ -46,6 +48,7 @@ public partial interface IUsersClient /// /// Username of the user /// + /// 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 CreateAsync( @@ -58,6 +61,7 @@ public partial interface IUsersClient string? lastName = default, string? phone = default, string? username = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IUsersClient.Delete.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IUsersClient.Delete.g.cs index 8496e15..9276b26 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IUsersClient.Delete.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IUsersClient.Delete.g.cs @@ -10,10 +10,12 @@ public partial interface IUsersClient /// <Warning>Use caution when deleting a user, as this can cause issues such as breaking the "Annotated by" filter or leaving orphaned records.</Warning> ///
/// + /// 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 DeleteAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IUsersClient.Get.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IUsersClient.Get.g.cs index 12001e8..9a54f0b 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IUsersClient.Get.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IUsersClient.Get.g.cs @@ -9,10 +9,12 @@ public partial interface IUsersClient /// Get info about a specific Label Studio user, based on the user ID. /// /// + /// 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 GetAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IUsersClient.GetCurrentUser.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IUsersClient.GetCurrentUser.g.cs index 1730007..e705b9f 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IUsersClient.GetCurrentUser.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IUsersClient.GetCurrentUser.g.cs @@ -14,9 +14,11 @@ public partial interface IUsersClient /// </Card>
/// Get info about the currently authenticated user. /// + /// 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 GetCurrentUserAsync( + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IUsersClient.GetHotkeys.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IUsersClient.GetHotkeys.g.cs index 0f7118f..727b0b9 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IUsersClient.GetHotkeys.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IUsersClient.GetHotkeys.g.cs @@ -8,9 +8,11 @@ public partial interface IUsersClient /// Get user hotkeys
/// Retrieve the custom hotkeys configuration for the current user. /// + /// 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 GetHotkeysAsync( + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IUsersClient.GetToken.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IUsersClient.GetToken.g.cs index cf32c78..6b15053 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IUsersClient.GetToken.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IUsersClient.GetToken.g.cs @@ -8,9 +8,11 @@ public partial interface IUsersClient /// Get user token
/// Get a user token to authenticate to the API as the current user. /// + /// 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 GetTokenAsync( + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IUsersClient.List.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IUsersClient.List.g.cs index 4cfadcd..29158ad 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IUsersClient.List.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IUsersClient.List.g.cs @@ -9,10 +9,12 @@ public partial interface IUsersClient /// List the users that exist on the Label Studio server. /// /// + /// 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> ListAsync( string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IUsersClient.ResetToken.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IUsersClient.ResetToken.g.cs index 84ce47c..9355881 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IUsersClient.ResetToken.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IUsersClient.ResetToken.g.cs @@ -8,9 +8,11 @@ public partial interface IUsersClient /// Reset user token
/// Reset the user token for the current user. /// + /// 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 ResetTokenAsync( + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IUsersClient.Update.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IUsersClient.Update.g.cs index fa3b9f2..cc4b519 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IUsersClient.Update.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IUsersClient.Update.g.cs @@ -11,12 +11,14 @@ public partial interface IUsersClient /// /// /// + /// 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 UpdateAsync( int id, global::LabelStudio.ApiUsersPartialUpdateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Update user details
@@ -51,6 +53,7 @@ public partial interface IUsersClient /// /// Username of the user /// + /// 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 UpdateAsync( @@ -64,6 +67,7 @@ public partial interface IUsersClient string? lastName = default, string? phone = default, string? username = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IUsersClient.UpdateCurrentUser.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IUsersClient.UpdateCurrentUser.g.cs index 8b58e12..49cde32 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IUsersClient.UpdateCurrentUser.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IUsersClient.UpdateCurrentUser.g.cs @@ -15,11 +15,13 @@ public partial interface IUsersClient /// Update details for the currently authenticated user. ///
/// + /// 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 UpdateCurrentUserAsync( global::LabelStudio.PatchedLseUserSerializerUpdateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Update current user
@@ -55,6 +57,7 @@ public partial interface IUsersClient /// /// /// + /// 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 UpdateCurrentUserAsync( @@ -70,6 +73,7 @@ public partial interface IUsersClient string? lastName = default, string? phone = default, string? username = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IUsersClient.UpdateHotkeys.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IUsersClient.UpdateHotkeys.g.cs index 2de2b5b..d231028 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IUsersClient.UpdateHotkeys.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IUsersClient.UpdateHotkeys.g.cs @@ -9,21 +9,25 @@ public partial interface IUsersClient /// Update the custom hotkeys configuration for the current user. ///
/// + /// 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 UpdateHotkeysAsync( global::LabelStudio.PatchedHotkeysRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Update user hotkeys
/// Update the custom hotkeys configuration for the current user. ///
/// + /// 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 UpdateHotkeysAsync( object? customHotkeys = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IUsersClient.Whoami.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IUsersClient.Whoami.g.cs index b418305..193b570 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IUsersClient.Whoami.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IUsersClient.Whoami.g.cs @@ -8,9 +8,11 @@ public partial interface IUsersClient /// Retrieve my user
/// Retrieve details of the account that you are using to access the API. /// + /// 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 WhoamiAsync( + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IUsersClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IUsersClient.g.cs index 5fbf7c8..9b8e260 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IUsersClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IUsersClient.g.cs @@ -33,6 +33,11 @@ public partial interface IUsersClient : global::System.IDisposable /// public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IVersionsClient.Get.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IVersionsClient.Get.g.cs index fa46530..3179f21 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IVersionsClient.Get.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IVersionsClient.Get.g.cs @@ -8,9 +8,11 @@ public partial interface IVersionsClient /// Get version information
/// Get version information about the Label Studio instance. /// + /// 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 GetAsync( + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IVersionsClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IVersionsClient.g.cs index c14fab1..b160968 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IVersionsClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IVersionsClient.g.cs @@ -33,6 +33,11 @@ public partial interface IVersionsClient : global::System.IDisposable /// public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IViewsClient.Create2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IViewsClient.Create2.g.cs index 11b43fa..078ccb0 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IViewsClient.Create2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IViewsClient.Create2.g.cs @@ -9,11 +9,13 @@ public partial interface IViewsClient /// Create a view for a specific project. /// /// + /// 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 Create2Async( global::LabelStudio.ApiDmViewsCreateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Create view
@@ -25,11 +27,13 @@ public partial interface IViewsClient /// /// Project ID /// + /// 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 Create2Async( global::LabelStudio.ApiDmViewsCreateRequestData? data = default, int? project = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IViewsClient.Delete.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IViewsClient.Delete.g.cs index c4d9f72..eabc68a 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IViewsClient.Delete.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IViewsClient.Delete.g.cs @@ -9,10 +9,12 @@ public partial interface IViewsClient /// Delete a specific view by ID. ///
/// + /// 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 DeleteAsync( string id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IViewsClient.DeleteAll.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IViewsClient.DeleteAll.g.cs index 96b1d56..b4a2218 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IViewsClient.DeleteAll.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IViewsClient.DeleteAll.g.cs @@ -9,10 +9,12 @@ public partial interface IViewsClient /// Delete all views for a specific project. /// /// + /// 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 DeleteAllAsync( int project, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IViewsClient.Get.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IViewsClient.Get.g.cs index fc3391e..e0e9284 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IViewsClient.Get.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IViewsClient.Get.g.cs @@ -9,10 +9,12 @@ public partial interface IViewsClient /// Get the details about a specific view in the data manager /// /// + /// 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 GetAsync( string id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IViewsClient.List2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IViewsClient.List2.g.cs index 4a78758..04b281a 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IViewsClient.List2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IViewsClient.List2.g.cs @@ -9,10 +9,12 @@ public partial interface IViewsClient /// List all views for a specific project. /// /// + /// 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> List2Async( int? project = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IViewsClient.Update.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IViewsClient.Update.g.cs index 83da8a6..f007fa3 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IViewsClient.Update.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IViewsClient.Update.g.cs @@ -10,12 +10,14 @@ public partial interface IViewsClient /// /// /// + /// 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 UpdateAsync( string id, global::LabelStudio.ApiDmViewsPartialUpdateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Update view
@@ -28,12 +30,14 @@ public partial interface IViewsClient /// /// Project ID /// + /// 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 UpdateAsync( string id, global::LabelStudio.ApiDmViewsPartialUpdateRequestData? data = default, int? project = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IViewsClient.UpdateOrder.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IViewsClient.UpdateOrder.g.cs index 5d6d1db..16dd0a9 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IViewsClient.UpdateOrder.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IViewsClient.UpdateOrder.g.cs @@ -9,11 +9,13 @@ public partial interface IViewsClient /// Update the order field of views based on the provided list of view 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 UpdateOrderAsync( global::LabelStudio.ViewOrderRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Update order of views
@@ -23,11 +25,13 @@ public partial interface IViewsClient /// A list of view IDs in the desired order. /// /// + /// 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 UpdateOrderAsync( global::System.Collections.Generic.IList ids, int project, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IViewsClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IViewsClient.g.cs index ecbae1a..d7f7394 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IViewsClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IViewsClient.g.cs @@ -33,6 +33,11 @@ public partial interface IViewsClient : global::System.IDisposable ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IWebhooks2Client.Create.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IWebhooks2Client.Create.g.cs index 781d2ea..1ac53aa 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IWebhooks2Client.Create.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IWebhooks2Client.Create.g.cs @@ -9,11 +9,13 @@ public partial interface IWebhooks2Client /// Create a webhook for your 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 CreateAsync( global::LabelStudio.WebhookRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Create a webhook
@@ -38,6 +40,7 @@ public partial interface IWebhooks2Client /// /// URL of webhook /// + /// 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 CreateAsync( @@ -48,6 +51,7 @@ public partial interface IWebhooks2Client int? project = default, bool? sendForAllActions = default, bool? sendPayload = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IWebhooks2Client.Delete.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IWebhooks2Client.Delete.g.cs index b37387f..ea8b021 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IWebhooks2Client.Delete.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IWebhooks2Client.Delete.g.cs @@ -8,10 +8,12 @@ public partial interface IWebhooks2Client /// Delete webhook info ///
/// + /// 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 DeleteAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IWebhooks2Client.Get.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IWebhooks2Client.Get.g.cs index 1997792..d45c872 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IWebhooks2Client.Get.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IWebhooks2Client.Get.g.cs @@ -8,10 +8,12 @@ public partial interface IWebhooks2Client /// Get webhook info /// /// + /// 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 GetAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IWebhooks2Client.Info.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IWebhooks2Client.Info.g.cs index 8805bcc..efe6d40 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IWebhooks2Client.Info.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IWebhooks2Client.Info.g.cs @@ -9,10 +9,12 @@ public partial interface IWebhooks2Client /// Get descriptions of all available webhook actions to set up webhooks. /// /// + /// 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( bool? organizationOnly = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IWebhooks2Client.List.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IWebhooks2Client.List.g.cs index e7d5232..25ab06a 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IWebhooks2Client.List.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IWebhooks2Client.List.g.cs @@ -9,10 +9,12 @@ public partial interface IWebhooks2Client /// List all webhooks set up for your 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> ListAsync( string? project = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IWebhooks2Client.Update.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IWebhooks2Client.Update.g.cs index 60d2d42..dd35ed3 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IWebhooks2Client.Update.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IWebhooks2Client.Update.g.cs @@ -9,12 +9,14 @@ public partial interface IWebhooks2Client /// /// /// + /// 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 UpdateAsync( int id, global::LabelStudio.PatchedWebhookSerializerForUpdateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Update webhook info @@ -38,6 +40,7 @@ public partial interface IWebhooks2Client /// /// URL of webhook /// + /// 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 UpdateAsync( @@ -48,6 +51,7 @@ public partial interface IWebhooks2Client bool? sendForAllActions = default, bool? sendPayload = default, string? url = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IWebhooks2Client.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IWebhooks2Client.g.cs index 0c9052b..f7c461b 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IWebhooks2Client.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IWebhooks2Client.g.cs @@ -33,6 +33,11 @@ public partial interface IWebhooks2Client : global::System.IDisposable /// public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IWebhooksClient.ApiWebhooksUpdate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IWebhooksClient.ApiWebhooksUpdate.g.cs index a783230..5c57079 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IWebhooksClient.ApiWebhooksUpdate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IWebhooksClient.ApiWebhooksUpdate.g.cs @@ -9,12 +9,14 @@ public partial interface IWebhooksClient /// /// /// + /// 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 ApiWebhooksUpdateAsync( int id, global::LabelStudio.WebhookSerializerForUpdateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Save webhook info @@ -38,6 +40,7 @@ public partial interface IWebhooksClient /// /// URL of webhook /// + /// 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 ApiWebhooksUpdateAsync( @@ -48,6 +51,7 @@ public partial interface IWebhooksClient bool? isActive = default, bool? sendForAllActions = default, bool? sendPayload = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IWebhooksClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IWebhooksClient.g.cs index db02176..6ba06a6 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IWebhooksClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IWebhooksClient.g.cs @@ -33,6 +33,11 @@ public partial interface IWebhooksClient : global::System.IDisposable /// public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IWorkspaces2Client.Create.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IWorkspaces2Client.Create.g.cs index 51e3dad..d88dbda 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IWorkspaces2Client.Create.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IWorkspaces2Client.Create.g.cs @@ -15,11 +15,13 @@ public partial interface IWorkspaces2Client /// Create a new workspace. Workspaces in Label Studio let you organize your projects and users into separate spaces. This is useful for managing different teams, departments, or projects within your organization. For more information, see the [Workspaces documentation](https://docs.humansignal.com/workspaces). /// /// + /// 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 CreateAsync( global::LabelStudio.WorkspaceRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Create workspace
@@ -46,6 +48,7 @@ public partial interface IWorkspaces2Client /// /// Workspace Name /// + /// 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 CreateAsync( @@ -54,6 +57,7 @@ public partial interface IWorkspaces2Client string? description = default, bool? isArchived = default, bool? isPersonal = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IWorkspaces2Client.Delete.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IWorkspaces2Client.Delete.g.cs index 14d16fb..25509c7 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IWorkspaces2Client.Delete.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IWorkspaces2Client.Delete.g.cs @@ -15,10 +15,12 @@ public partial interface IWorkspaces2Client /// Delete a specific workspace by ID. ///
/// + /// 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 DeleteAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IWorkspaces2Client.Get.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IWorkspaces2Client.Get.g.cs index f14a09b..e40ae96 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IWorkspaces2Client.Get.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IWorkspaces2Client.Get.g.cs @@ -15,10 +15,12 @@ public partial interface IWorkspaces2Client /// Retrieve details for a specific workspace by ID. /// /// + /// 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 GetAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IWorkspaces2Client.List.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IWorkspaces2Client.List.g.cs index cedf38e..f9e52ee 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IWorkspaces2Client.List.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IWorkspaces2Client.List.g.cs @@ -18,6 +18,7 @@ public partial interface IWorkspaces2Client /// /// /// + /// 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> ListAsync( @@ -25,6 +26,7 @@ public partial interface IWorkspaces2Client bool? isArchived = default, bool? isPersonal = default, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IWorkspaces2Client.Update.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IWorkspaces2Client.Update.g.cs index 9abcecc..a5fc028 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IWorkspaces2Client.Update.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IWorkspaces2Client.Update.g.cs @@ -16,12 +16,14 @@ public partial interface IWorkspaces2Client /// /// /// + /// 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 UpdateAsync( int id, global::LabelStudio.PatchedWorkspaceRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Update workspace
@@ -49,6 +51,7 @@ public partial interface IWorkspaces2Client /// /// Workspace Name /// + /// 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 UpdateAsync( @@ -58,6 +61,7 @@ public partial interface IWorkspaces2Client bool? isArchived = default, bool? isPersonal = default, string? title = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IWorkspaces2Client.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IWorkspaces2Client.g.cs index b02d847..cf5f6d4 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IWorkspaces2Client.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IWorkspaces2Client.g.cs @@ -33,6 +33,11 @@ public partial interface IWorkspaces2Client : global::System.IDisposable ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IWorkspacesClient.Add.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IWorkspacesClient.Add.g.cs index 47e2c90..4783209 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IWorkspacesClient.Add.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IWorkspacesClient.Add.g.cs @@ -16,12 +16,14 @@ public partial interface IWorkspacesClient /// /// /// + /// 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 AddAsync( int id, global::LabelStudio.WorkspaceProjectsRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Add workspace project
@@ -37,11 +39,13 @@ public partial interface IWorkspacesClient /// /// Project ID /// + /// 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 AddAsync( int id, int project, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IWorkspacesClient.Create2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IWorkspacesClient.Create2.g.cs index b9975f8..eb43f95 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IWorkspacesClient.Create2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IWorkspacesClient.Create2.g.cs @@ -16,12 +16,14 @@ public partial interface IWorkspacesClient ///
/// /// + /// 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 Create2Async( int id, global::LabelStudio.WorkspaceMemberCreateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Create workspace membership
@@ -40,12 +42,14 @@ public partial interface IWorkspacesClient /// /// Workspace ID /// + /// 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 Create2Async( int id, int user, int? workspace = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IWorkspacesClient.Delete2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IWorkspacesClient.Delete2.g.cs index a4dfc27..53ab147 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IWorkspacesClient.Delete2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IWorkspacesClient.Delete2.g.cs @@ -16,11 +16,13 @@ public partial interface IWorkspacesClient ///
/// /// + /// 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 Delete2Async( int id, int? userId = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IWorkspacesClient.Delete3.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IWorkspacesClient.Delete3.g.cs index 3943810..87c43a0 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IWorkspacesClient.Delete3.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IWorkspacesClient.Delete3.g.cs @@ -20,6 +20,7 @@ public partial interface IWorkspacesClient /// /// /// + /// 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 Delete3Async( @@ -29,6 +30,7 @@ public partial interface IWorkspacesClient string? ids = default, string? included = default, string? search = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IWorkspacesClient.List2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IWorkspacesClient.List2.g.cs index 8214f28..108318a 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IWorkspacesClient.List2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IWorkspacesClient.List2.g.cs @@ -15,10 +15,12 @@ public partial interface IWorkspacesClient /// Get a list of all members in a specific workspace. /// /// + /// 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> List2Async( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IWorkspacesClient.List3.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IWorkspacesClient.List3.g.cs index cd586f6..88a92bd 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IWorkspacesClient.List3.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IWorkspacesClient.List3.g.cs @@ -19,6 +19,7 @@ public partial interface IWorkspacesClient /// /// /// + /// 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 List3Async( @@ -27,6 +28,7 @@ public partial interface IWorkspacesClient int? page = default, int? pageSize = default, string? search = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IWorkspacesClient.List4.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IWorkspacesClient.List4.g.cs index bd843f7..3293aac 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IWorkspacesClient.List4.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IWorkspacesClient.List4.g.cs @@ -15,10 +15,12 @@ public partial interface IWorkspacesClient /// Retrieve a list of all projects in a specific workspace. /// /// + /// 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> List4Async( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IWorkspacesClient.Post.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IWorkspacesClient.Post.g.cs index 2ecb345..e6b9e7b 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IWorkspacesClient.Post.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IWorkspacesClient.Post.g.cs @@ -16,12 +16,14 @@ public partial interface IWorkspacesClient /// /// /// + /// 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 PostAsync( int id, global::LabelStudio.WorkspaceMemberBulkAssignRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// ✨ Bulk assign workspace members
@@ -43,6 +45,7 @@ public partial interface IWorkspacesClient /// /// Included user 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 PostAsync( @@ -50,6 +53,7 @@ public partial interface IWorkspacesClient bool all, global::System.Collections.Generic.IList? excluded = default, global::System.Collections.Generic.IList? included = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IWorkspacesClient.Remove.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IWorkspacesClient.Remove.g.cs index e31a3b3..c0efe3e 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IWorkspacesClient.Remove.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IWorkspacesClient.Remove.g.cs @@ -16,11 +16,13 @@ public partial interface IWorkspacesClient ///
/// /// + /// 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 RemoveAsync( int id, int? project = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IWorkspacesClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IWorkspacesClient.g.cs index 8edaa23..80350e4 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IWorkspacesClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IWorkspacesClient.g.cs @@ -33,6 +33,11 @@ public partial interface IWorkspacesClient : global::System.IDisposable /// public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ImportClient.Delete.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ImportClient.Delete.g.cs index 7261b98..89130e4 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ImportClient.Delete.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ImportClient.Delete.g.cs @@ -14,6 +14,7 @@ public partial class ImportClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -40,10 +41,12 @@ partial void ProcessDeleteResponse( /// Delete a specific 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 DeleteAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -58,22 +61,43 @@ partial void ProcessDeleteResponse( securityRequirements: s_DeleteSecurityRequirements, operationName: "DeleteAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/import/file-upload/{id}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/import/file-upload/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -83,96 +107,255 @@ partial void ProcessDeleteResponse( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDeleteRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDeleteRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/import/file-upload/{id}\"", + 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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/import/file-upload/{id}\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessDeleteResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/import/file-upload/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessDeleteResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/import/file-upload/{id}\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/import/file-upload/{id}\"", + httpMethod: "DELETE", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.ImportClient.DeleteMany.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ImportClient.DeleteMany.g.cs index 9632c4a..e2f506f 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ImportClient.DeleteMany.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ImportClient.DeleteMany.g.cs @@ -14,6 +14,7 @@ public partial class ImportClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -41,10 +42,12 @@ partial void ProcessDeleteManyResponse( /// /// /// + /// 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 DeleteManyAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -59,22 +62,43 @@ partial void ProcessDeleteManyResponse( securityRequirements: s_DeleteManySecurityRequirements, operationName: "DeleteManyAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{id}/file-uploads", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{id}/file-uploads", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -84,96 +108,255 @@ partial void ProcessDeleteManyResponse( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDeleteManyRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDeleteManyRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteMany", + methodName: "DeleteManyAsync", + pathTemplate: "$\"/api/projects/{id}/file-uploads\"", + 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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteMany", + methodName: "DeleteManyAsync", + pathTemplate: "$\"/api/projects/{id}/file-uploads\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessDeleteManyResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteMany", + methodName: "DeleteManyAsync", + pathTemplate: "$\"/api/projects/{id}/file-uploads\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessDeleteManyResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteMany", + methodName: "DeleteManyAsync", + pathTemplate: "$\"/api/projects/{id}/file-uploads\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteMany", + methodName: "DeleteManyAsync", + pathTemplate: "$\"/api/projects/{id}/file-uploads\"", + httpMethod: "DELETE", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.ImportClient.Download.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ImportClient.Download.g.cs index 7b9e4ad..9a87012 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ImportClient.Download.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ImportClient.Download.g.cs @@ -14,6 +14,7 @@ public partial class ImportClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -40,10 +41,12 @@ partial void ProcessDownloadResponse( /// Download a specific 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 DownloadAsync( string filename, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -58,22 +61,43 @@ partial void ProcessDownloadResponse( securityRequirements: s_DownloadSecurityRequirements, operationName: "DownloadAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/data/upload/{filename}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/data/upload/{filename}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,96 +107,255 @@ partial void ProcessDownloadResponse( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDownloadRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - filename: filename); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDownloadRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + filename: filename); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Download", + methodName: "DownloadAsync", + pathTemplate: "$\"/data/upload/{filename}\"", + 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: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Download", + methodName: "DownloadAsync", + pathTemplate: "$\"/data/upload/{filename}\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessDownloadResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Download", + methodName: "DownloadAsync", + pathTemplate: "$\"/data/upload/{filename}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessDownloadResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Download", + methodName: "DownloadAsync", + pathTemplate: "$\"/data/upload/{filename}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Download", + methodName: "DownloadAsync", + pathTemplate: "$\"/data/upload/{filename}\"", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.ImportClient.Get.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ImportClient.Get.g.cs index d58153b..0c8d71c 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ImportClient.Get.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ImportClient.Get.g.cs @@ -14,6 +14,7 @@ public partial class ImportClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,10 +46,12 @@ partial void ProcessGetResponseContent( /// Retrieve details about a specific 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 GetAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -63,22 +66,43 @@ partial void ProcessGetResponseContent( securityRequirements: s_GetSecurityRequirements, operationName: "GetAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/import/file-upload/{id}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/import/file-upload/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -88,112 +112,271 @@ partial void ProcessGetResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/import/file-upload/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/import/file-upload/{id}\"", + 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); - ProcessGetResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/import/file-upload/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.FileUpload.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.FileUpload.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGetResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/import/file-upload/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/import/file-upload/{id}\"", + 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); + ProcessGetResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.FileUpload.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.FileUpload.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.ImportClient.List.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ImportClient.List.g.cs index cba94a9..1ec0551 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ImportClient.List.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ImportClient.List.g.cs @@ -14,6 +14,7 @@ public partial class ImportClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -55,6 +56,7 @@ partial void ProcessListResponseContent( /// /// /// + /// 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> ListAsync( @@ -62,6 +64,7 @@ partial void ProcessListResponseContent( bool? all = default, global::System.Collections.Generic.IList? ids = default, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -79,27 +82,48 @@ partial void ProcessListResponseContent( securityRequirements: s_ListSecurityRequirements, operationName: "ListAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{id}/file-uploads", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("all", all?.ToString().ToLowerInvariant()) - .AddOptionalParameter("ids", ids, delimiter: ",", explode: true) - .AddOptionalParameter("ordering", ordering) - ; - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{id}/file-uploads", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("all", all?.ToString().ToLowerInvariant()) + .AddOptionalParameter("ids", ids, delimiter: ",", explode: true) + .AddOptionalParameter("ordering", ordering) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -109,115 +133,274 @@ partial void ProcessListResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareListRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - all: all, - id: id, - ids: ids, - ordering: ordering); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareListRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + all: all, + id: id, + ids: ids, + ordering: ordering); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessListResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "$\"/api/projects/{id}/file-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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "$\"/api/projects/{id}/file-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); - ProcessListResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "$\"/api/projects/{id}/file-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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessListResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "$\"/api/projects/{id}/file-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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "$\"/api/projects/{id}/file-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); + ProcessListResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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 + (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.ImportClient.Update.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ImportClient.Update.g.cs index 051125d..1f564a2 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ImportClient.Update.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ImportClient.Update.g.cs @@ -14,6 +14,7 @@ public partial class ImportClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -48,12 +49,14 @@ partial void ProcessUpdateResponseContent( /// /// /// + /// 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 UpdateAsync( int id, global::LabelStudio.PatchedFileUploadRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -71,22 +74,43 @@ partial void ProcessUpdateResponseContent( securityRequirements: s_UpdateSecurityRequirements, operationName: "UpdateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/import/file-upload/{id}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/import/file-upload/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -96,119 +120,278 @@ partial void ProcessUpdateResponseContent( __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); - PrepareUpdateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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::LabelStudio.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); + PrepareUpdateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessUpdateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/import/file-upload/{id}\"", + 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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/import/file-upload/{id}\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessUpdateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/import/file-upload/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.FileUpload.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.FileUpload.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessUpdateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/import/file-upload/{id}\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/import/file-upload/{id}\"", + httpMethod: "PATCH", + 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); + ProcessUpdateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.FileUpload.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.FileUpload.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 upload
@@ -217,12 +400,14 @@ partial void ProcessUpdateResponseContent( /// /// /// + /// 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 UpdateAsync( int id, byte[]? file = default, string? filename = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.PatchedFileUploadRequest @@ -234,6 +419,7 @@ partial void ProcessUpdateResponseContent( return await UpdateAsync( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ImportClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ImportClient.g.cs index 47a2448..60b4aec 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ImportClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ImportClient.g.cs @@ -30,6 +30,9 @@ public sealed partial class ImportClient : global::LabelStudio.IImportClient, gl #if DEBUG = true; #endif + + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public ImportClient( 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 ImportClient. + /// 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 ImportClient( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::LabelStudio.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::LabelStudio.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/LabelStudio/Generated/LabelStudio.JwtSettingsClient.Get.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.JwtSettingsClient.Get.g.cs index 8073774..12820c0 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.JwtSettingsClient.Get.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.JwtSettingsClient.Get.g.cs @@ -14,6 +14,7 @@ public partial class JwtSettingsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -42,9 +43,11 @@ partial void ProcessGetResponseContent( /// Retrieve JWT Settings
/// Retrieve JWT settings for the currently active 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 GetAsync( + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -58,22 +61,43 @@ partial void ProcessGetResponseContent( securityRequirements: s_GetSecurityRequirements, operationName: "GetAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/jwt/settings", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/jwt/settings", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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 ProcessGetResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetRequest( - 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); + PrepareGetRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "\"/api/jwt/settings\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "\"/api/jwt/settings\"", + 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); - ProcessGetResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "\"/api/jwt/settings\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.LSEJWTSettings.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.LSEJWTSettings.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGetResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "\"/api/jwt/settings\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "\"/api/jwt/settings\"", + 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); + ProcessGetResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.LSEJWTSettings.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.LSEJWTSettings.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.JwtSettingsClient.Update.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.JwtSettingsClient.Update.g.cs index cf5714c..3617c3f 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.JwtSettingsClient.Update.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.JwtSettingsClient.Update.g.cs @@ -14,6 +14,7 @@ public partial class JwtSettingsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,11 +46,13 @@ partial void ProcessUpdateResponseContent( /// Update JWT settings for the currently active 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 UpdateAsync( global::LabelStudio.LSEJWTSettingsRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -66,22 +69,43 @@ partial void ProcessUpdateResponseContent( securityRequirements: s_UpdateSecurityRequirements, operationName: "UpdateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/jwt/settings", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/jwt/settings", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,118 +115,277 @@ partial void ProcessUpdateResponseContent( __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); - PrepareUpdateRequest( - 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::LabelStudio.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); + PrepareUpdateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessUpdateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "\"/api/jwt/settings\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "\"/api/jwt/settings\"", + 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); - ProcessUpdateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "\"/api/jwt/settings\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.LSEJWTSettings.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.LSEJWTSettings.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessUpdateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "\"/api/jwt/settings\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "\"/api/jwt/settings\"", + 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); + ProcessUpdateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.LSEJWTSettings.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.LSEJWTSettings.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 JWT Settings
@@ -215,12 +398,14 @@ partial void ProcessUpdateResponseContent( /// /// Enable legacy API token authentication for this 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 UpdateAsync( int apiTokenTtlDays, bool? apiTokensEnabled = default, bool? legacyApiTokensEnabled = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.LSEJWTSettingsRequest @@ -232,6 +417,7 @@ partial void ProcessUpdateResponseContent( return await UpdateAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.JwtSettingsClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.JwtSettingsClient.g.cs index 7f8ffd9..928ec0e 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.JwtSettingsClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.JwtSettingsClient.g.cs @@ -30,6 +30,9 @@ public sealed partial class JwtSettingsClient : global::LabelStudio.IJwtSettings #if DEBUG = true; #endif + + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public JwtSettingsClient( 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 JwtSettingsClient. + /// 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 JwtSettingsClient( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::LabelStudio.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::LabelStudio.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/LabelStudio/Generated/LabelStudio.LabelStudioClient.Authorizations.Bearer.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.LabelStudioClient.Authorizations.Bearer.g.cs index cb3f087..c701ca2 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.LabelStudioClient.Authorizations.Bearer.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.LabelStudioClient.Authorizations.Bearer.g.cs @@ -25,6 +25,7 @@ public void AuthorizeUsingBearer( Authorizations.Add(new global::LabelStudio.EndPointAuthorization { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", Value = apiKey, diff --git a/src/libs/LabelStudio/Generated/LabelStudio.LabelStudioClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.LabelStudioClient.g.cs index 102f28a..791a977 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.LabelStudioClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.LabelStudioClient.g.cs @@ -31,6 +31,9 @@ public sealed partial class LabelStudioClient : global::LabelStudio.ILabelStudio #if DEBUG = true; #endif + + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } /// /// /// @@ -40,7 +43,7 @@ public sealed partial class LabelStudioClient : global::LabelStudio.ILabelStudio /// /// /// - public ActionsClient Actions => new ActionsClient(HttpClient, authorizations: Authorizations) + public ActionsClient Actions => new ActionsClient(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -49,7 +52,7 @@ public sealed partial class LabelStudioClient : global::LabelStudio.ILabelStudio /// /// /// - public ActivityLogsClient ActivityLogs => new ActivityLogsClient(HttpClient, authorizations: Authorizations) + public ActivityLogsClient ActivityLogs => new ActivityLogsClient(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -58,7 +61,7 @@ public sealed partial class LabelStudioClient : global::LabelStudio.ILabelStudio /// /// /// - public AnalyticsClient Analytics => new AnalyticsClient(HttpClient, authorizations: Authorizations) + public AnalyticsClient Analytics => new AnalyticsClient(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -67,7 +70,7 @@ public sealed partial class LabelStudioClient : global::LabelStudio.ILabelStudio /// /// /// - public AnnotationHistoryClient AnnotationHistory => new AnnotationHistoryClient(HttpClient, authorizations: Authorizations) + public AnnotationHistoryClient AnnotationHistory => new AnnotationHistoryClient(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -76,7 +79,7 @@ public sealed partial class LabelStudioClient : global::LabelStudio.ILabelStudio /// /// /// - public AnnotationReviewsClient AnnotationReviews => new AnnotationReviewsClient(HttpClient, authorizations: Authorizations) + public AnnotationReviewsClient AnnotationReviews => new AnnotationReviewsClient(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -85,7 +88,7 @@ public sealed partial class LabelStudioClient : global::LabelStudio.ILabelStudio /// /// /// - public AnnotationReviews2Client AnnotationReviews2 => new AnnotationReviews2Client(HttpClient, authorizations: Authorizations) + public AnnotationReviews2Client AnnotationReviews2 => new AnnotationReviews2Client(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -94,7 +97,7 @@ public sealed partial class LabelStudioClient : global::LabelStudio.ILabelStudio /// /// /// - public AnnotationsClient Annotations => new AnnotationsClient(HttpClient, authorizations: Authorizations) + public AnnotationsClient Annotations => new AnnotationsClient(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -103,7 +106,7 @@ public sealed partial class LabelStudioClient : global::LabelStudio.ILabelStudio /// /// /// - public AwsClient Aws => new AwsClient(HttpClient, authorizations: Authorizations) + public AwsClient Aws => new AwsClient(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -112,7 +115,7 @@ public sealed partial class LabelStudioClient : global::LabelStudio.ILabelStudio /// /// /// - public BillingClient Billing => new BillingClient(HttpClient, authorizations: Authorizations) + public BillingClient Billing => new BillingClient(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -121,7 +124,7 @@ public sealed partial class LabelStudioClient : global::LabelStudio.ILabelStudio /// /// /// - public BlueprintsClient Blueprints => new BlueprintsClient(HttpClient, authorizations: Authorizations) + public BlueprintsClient Blueprints => new BlueprintsClient(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -130,7 +133,7 @@ public sealed partial class LabelStudioClient : global::LabelStudio.ILabelStudio /// /// /// - public Blueprints2Client Blueprints2 => new Blueprints2Client(HttpClient, authorizations: Authorizations) + public Blueprints2Client Blueprints2 => new Blueprints2Client(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -139,7 +142,7 @@ public sealed partial class LabelStudioClient : global::LabelStudio.ILabelStudio /// /// /// - public CommentsClient Comments => new CommentsClient(HttpClient, authorizations: Authorizations) + public CommentsClient Comments => new CommentsClient(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -148,7 +151,7 @@ public sealed partial class LabelStudioClient : global::LabelStudio.ILabelStudio /// /// /// - public Comments2Client Comments2 => new Comments2Client(HttpClient, authorizations: Authorizations) + public Comments2Client Comments2 => new Comments2Client(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -157,7 +160,7 @@ public sealed partial class LabelStudioClient : global::LabelStudio.ILabelStudio /// /// /// - public DataExplorerClient DataExplorer => new DataExplorerClient(HttpClient, authorizations: Authorizations) + public DataExplorerClient DataExplorer => new DataExplorerClient(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -166,7 +169,7 @@ public sealed partial class LabelStudioClient : global::LabelStudio.ILabelStudio /// /// /// - public DataManagerClient DataManager => new DataManagerClient(HttpClient, authorizations: Authorizations) + public DataManagerClient DataManager => new DataManagerClient(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -175,7 +178,7 @@ public sealed partial class LabelStudioClient : global::LabelStudio.ILabelStudio /// /// /// - public DatasetStorageAzureClient DatasetStorageAzure => new DatasetStorageAzureClient(HttpClient, authorizations: Authorizations) + public DatasetStorageAzureClient DatasetStorageAzure => new DatasetStorageAzureClient(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -184,7 +187,7 @@ public sealed partial class LabelStudioClient : global::LabelStudio.ILabelStudio /// /// /// - public DatasetStorageGcsClient DatasetStorageGcs => new DatasetStorageGcsClient(HttpClient, authorizations: Authorizations) + public DatasetStorageGcsClient DatasetStorageGcs => new DatasetStorageGcsClient(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -193,7 +196,7 @@ public sealed partial class LabelStudioClient : global::LabelStudio.ILabelStudio /// /// /// - public DatasetStorageS3Client DatasetStorageS3 => new DatasetStorageS3Client(HttpClient, authorizations: Authorizations) + public DatasetStorageS3Client DatasetStorageS3 => new DatasetStorageS3Client(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -202,7 +205,7 @@ public sealed partial class LabelStudioClient : global::LabelStudio.ILabelStudio /// /// /// - public DatasetsClient Datasets => new DatasetsClient(HttpClient, authorizations: Authorizations) + public DatasetsClient Datasets => new DatasetsClient(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -211,7 +214,7 @@ public sealed partial class LabelStudioClient : global::LabelStudio.ILabelStudio /// /// /// - public DimensionsClient Dimensions => new DimensionsClient(HttpClient, authorizations: Authorizations) + public DimensionsClient Dimensions => new DimensionsClient(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -220,7 +223,7 @@ public sealed partial class LabelStudioClient : global::LabelStudio.ILabelStudio /// /// /// - public Dimensions2Client Dimensions2 => new Dimensions2Client(HttpClient, authorizations: Authorizations) + public Dimensions2Client Dimensions2 => new Dimensions2Client(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -229,7 +232,7 @@ public sealed partial class LabelStudioClient : global::LabelStudio.ILabelStudio /// /// /// - public ExportClient Export => new ExportClient(HttpClient, authorizations: Authorizations) + public ExportClient Export => new ExportClient(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -238,7 +241,7 @@ public sealed partial class LabelStudioClient : global::LabelStudio.ILabelStudio /// /// /// - public ImportClient Import => new ImportClient(HttpClient, authorizations: Authorizations) + public ImportClient Import => new ImportClient(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -247,7 +250,7 @@ public sealed partial class LabelStudioClient : global::LabelStudio.ILabelStudio /// /// /// - public JwtSettingsClient JwtSettings => new JwtSettingsClient(HttpClient, authorizations: Authorizations) + public JwtSettingsClient JwtSettings => new JwtSettingsClient(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -256,7 +259,7 @@ public sealed partial class LabelStudioClient : global::LabelStudio.ILabelStudio /// /// /// - public LabelsClient Labels => new LabelsClient(HttpClient, authorizations: Authorizations) + public LabelsClient Labels => new LabelsClient(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -265,7 +268,7 @@ public sealed partial class LabelStudioClient : global::LabelStudio.ILabelStudio /// /// /// - public Labels2Client Labels2 => new Labels2Client(HttpClient, authorizations: Authorizations) + public Labels2Client Labels2 => new Labels2Client(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -274,7 +277,7 @@ public sealed partial class LabelStudioClient : global::LabelStudio.ILabelStudio /// /// /// - public LlmClient Llm => new LlmClient(HttpClient, authorizations: Authorizations) + public LlmClient Llm => new LlmClient(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -283,7 +286,7 @@ public sealed partial class LabelStudioClient : global::LabelStudio.ILabelStudio /// /// /// - public MlClient Ml => new MlClient(HttpClient, authorizations: Authorizations) + public MlClient Ml => new MlClient(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -292,7 +295,7 @@ public sealed partial class LabelStudioClient : global::LabelStudio.ILabelStudio /// /// /// - public ModelProviderConnectionClient ModelProviderConnection => new ModelProviderConnectionClient(HttpClient, authorizations: Authorizations) + public ModelProviderConnectionClient ModelProviderConnection => new ModelProviderConnectionClient(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -301,7 +304,7 @@ public sealed partial class LabelStudioClient : global::LabelStudio.ILabelStudio /// /// /// - public ModelProvidersClient ModelProviders => new ModelProvidersClient(HttpClient, authorizations: Authorizations) + public ModelProvidersClient ModelProviders => new ModelProvidersClient(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -310,7 +313,7 @@ public sealed partial class LabelStudioClient : global::LabelStudio.ILabelStudio /// /// /// - public OrganizationsClient Organizations => new OrganizationsClient(HttpClient, authorizations: Authorizations) + public OrganizationsClient Organizations => new OrganizationsClient(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -319,7 +322,7 @@ public sealed partial class LabelStudioClient : global::LabelStudio.ILabelStudio /// /// /// - public Organizations2Client Organizations2 => new Organizations2Client(HttpClient, authorizations: Authorizations) + public Organizations2Client Organizations2 => new Organizations2Client(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -328,7 +331,7 @@ public sealed partial class LabelStudioClient : global::LabelStudio.ILabelStudio /// /// /// - public PausesClient Pauses => new PausesClient(HttpClient, authorizations: Authorizations) + public PausesClient Pauses => new PausesClient(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -337,7 +340,7 @@ public sealed partial class LabelStudioClient : global::LabelStudio.ILabelStudio /// /// /// - public PredictionsClient Predictions => new PredictionsClient(HttpClient, authorizations: Authorizations) + public PredictionsClient Predictions => new PredictionsClient(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -346,7 +349,7 @@ public sealed partial class LabelStudioClient : global::LabelStudio.ILabelStudio /// /// /// - public Predictions2Client Predictions2 => new Predictions2Client(HttpClient, authorizations: Authorizations) + public Predictions2Client Predictions2 => new Predictions2Client(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -355,7 +358,7 @@ public sealed partial class LabelStudioClient : global::LabelStudio.ILabelStudio /// /// /// - public ProjectRolesClient ProjectRoles => new ProjectRolesClient(HttpClient, authorizations: Authorizations) + public ProjectRolesClient ProjectRoles => new ProjectRolesClient(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -364,7 +367,7 @@ public sealed partial class LabelStudioClient : global::LabelStudio.ILabelStudio /// /// /// - public ProjectTemplatesClient ProjectTemplates => new ProjectTemplatesClient(HttpClient, authorizations: Authorizations) + public ProjectTemplatesClient ProjectTemplates => new ProjectTemplatesClient(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -373,7 +376,7 @@ public sealed partial class LabelStudioClient : global::LabelStudio.ILabelStudio /// /// /// - public ProjectsClient Projects => new ProjectsClient(HttpClient, authorizations: Authorizations) + public ProjectsClient Projects => new ProjectsClient(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -382,7 +385,7 @@ public sealed partial class LabelStudioClient : global::LabelStudio.ILabelStudio /// /// /// - public Projects2Client Projects2 => new Projects2Client(HttpClient, authorizations: Authorizations) + public Projects2Client Projects2 => new Projects2Client(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -391,7 +394,7 @@ public sealed partial class LabelStudioClient : global::LabelStudio.ILabelStudio /// /// /// - public PromptsClient Prompts => new PromptsClient(HttpClient, authorizations: Authorizations) + public PromptsClient Prompts => new PromptsClient(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -400,7 +403,7 @@ public sealed partial class LabelStudioClient : global::LabelStudio.ILabelStudio /// /// /// - public Prompts2Client Prompts2 => new Prompts2Client(HttpClient, authorizations: Authorizations) + public Prompts2Client Prompts2 => new Prompts2Client(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -409,7 +412,7 @@ public sealed partial class LabelStudioClient : global::LabelStudio.ILabelStudio /// /// /// - public SessionPolicyClient SessionPolicy => new SessionPolicyClient(HttpClient, authorizations: Authorizations) + public SessionPolicyClient SessionPolicy => new SessionPolicyClient(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -418,7 +421,7 @@ public sealed partial class LabelStudioClient : global::LabelStudio.ILabelStudio /// /// /// - public SsoClient Sso => new SsoClient(HttpClient, authorizations: Authorizations) + public SsoClient Sso => new SsoClient(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -427,7 +430,7 @@ public sealed partial class LabelStudioClient : global::LabelStudio.ILabelStudio /// /// /// - public StatesClient States => new StatesClient(HttpClient, authorizations: Authorizations) + public StatesClient States => new StatesClient(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -436,7 +439,7 @@ public sealed partial class LabelStudioClient : global::LabelStudio.ILabelStudio /// /// /// - public StatsClient Stats => new StatsClient(HttpClient, authorizations: Authorizations) + public StatsClient Stats => new StatsClient(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -445,7 +448,7 @@ public sealed partial class LabelStudioClient : global::LabelStudio.ILabelStudio /// /// /// - public StorageClient Storage => new StorageClient(HttpClient, authorizations: Authorizations) + public StorageClient Storage => new StorageClient(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -454,7 +457,7 @@ public sealed partial class LabelStudioClient : global::LabelStudio.ILabelStudio /// /// /// - public StorageAzureClient StorageAzure => new StorageAzureClient(HttpClient, authorizations: Authorizations) + public StorageAzureClient StorageAzure => new StorageAzureClient(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -463,7 +466,7 @@ public sealed partial class LabelStudioClient : global::LabelStudio.ILabelStudio /// /// /// - public StorageAzureSpiClient StorageAzureSpi => new StorageAzureSpiClient(HttpClient, authorizations: Authorizations) + public StorageAzureSpiClient StorageAzureSpi => new StorageAzureSpiClient(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -472,7 +475,7 @@ public sealed partial class LabelStudioClient : global::LabelStudio.ILabelStudio /// /// /// - public StorageDatabricksFilesClient StorageDatabricksFiles => new StorageDatabricksFilesClient(HttpClient, authorizations: Authorizations) + public StorageDatabricksFilesClient StorageDatabricksFiles => new StorageDatabricksFilesClient(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -481,7 +484,7 @@ public sealed partial class LabelStudioClient : global::LabelStudio.ILabelStudio /// /// /// - public StorageGcsClient StorageGcs => new StorageGcsClient(HttpClient, authorizations: Authorizations) + public StorageGcsClient StorageGcs => new StorageGcsClient(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -490,7 +493,7 @@ public sealed partial class LabelStudioClient : global::LabelStudio.ILabelStudio /// /// /// - public StorageGcsSaClient StorageGcsSa => new StorageGcsSaClient(HttpClient, authorizations: Authorizations) + public StorageGcsSaClient StorageGcsSa => new StorageGcsSaClient(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -499,7 +502,7 @@ public sealed partial class LabelStudioClient : global::LabelStudio.ILabelStudio /// /// /// - public StorageGcsWifClient StorageGcsWif => new StorageGcsWifClient(HttpClient, authorizations: Authorizations) + public StorageGcsWifClient StorageGcsWif => new StorageGcsWifClient(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -508,7 +511,7 @@ public sealed partial class LabelStudioClient : global::LabelStudio.ILabelStudio /// /// /// - public StorageLocalClient StorageLocal => new StorageLocalClient(HttpClient, authorizations: Authorizations) + public StorageLocalClient StorageLocal => new StorageLocalClient(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -517,7 +520,7 @@ public sealed partial class LabelStudioClient : global::LabelStudio.ILabelStudio /// /// /// - public StorageRedisClient StorageRedis => new StorageRedisClient(HttpClient, authorizations: Authorizations) + public StorageRedisClient StorageRedis => new StorageRedisClient(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -526,7 +529,7 @@ public sealed partial class LabelStudioClient : global::LabelStudio.ILabelStudio /// /// /// - public StorageS3Client StorageS3 => new StorageS3Client(HttpClient, authorizations: Authorizations) + public StorageS3Client StorageS3 => new StorageS3Client(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -535,7 +538,7 @@ public sealed partial class LabelStudioClient : global::LabelStudio.ILabelStudio /// /// /// - public StorageS3RolesClient StorageS3Roles => new StorageS3RolesClient(HttpClient, authorizations: Authorizations) + public StorageS3RolesClient StorageS3Roles => new StorageS3RolesClient(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -544,7 +547,7 @@ public sealed partial class LabelStudioClient : global::LabelStudio.ILabelStudio /// /// /// - public TasksClient Tasks => new TasksClient(HttpClient, authorizations: Authorizations) + public TasksClient Tasks => new TasksClient(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -553,7 +556,7 @@ public sealed partial class LabelStudioClient : global::LabelStudio.ILabelStudio /// /// /// - public Tasks2Client Tasks2 => new Tasks2Client(HttpClient, authorizations: Authorizations) + public Tasks2Client Tasks2 => new Tasks2Client(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -562,7 +565,7 @@ public sealed partial class LabelStudioClient : global::LabelStudio.ILabelStudio /// /// /// - public TokensClient Tokens => new TokensClient(HttpClient, authorizations: Authorizations) + public TokensClient Tokens => new TokensClient(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -571,7 +574,7 @@ public sealed partial class LabelStudioClient : global::LabelStudio.ILabelStudio /// /// /// - public UsersClient Users => new UsersClient(HttpClient, authorizations: Authorizations) + public UsersClient Users => new UsersClient(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -580,7 +583,7 @@ public sealed partial class LabelStudioClient : global::LabelStudio.ILabelStudio /// /// /// - public VersionsClient Versions => new VersionsClient(HttpClient, authorizations: Authorizations) + public VersionsClient Versions => new VersionsClient(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -589,7 +592,7 @@ public sealed partial class LabelStudioClient : global::LabelStudio.ILabelStudio /// /// /// - public ViewsClient Views => new ViewsClient(HttpClient, authorizations: Authorizations) + public ViewsClient Views => new ViewsClient(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -598,7 +601,7 @@ public sealed partial class LabelStudioClient : global::LabelStudio.ILabelStudio /// /// /// - public WebhooksClient Webhooks => new WebhooksClient(HttpClient, authorizations: Authorizations) + public WebhooksClient Webhooks => new WebhooksClient(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -607,7 +610,7 @@ public sealed partial class LabelStudioClient : global::LabelStudio.ILabelStudio /// /// /// - public Webhooks2Client Webhooks2 => new Webhooks2Client(HttpClient, authorizations: Authorizations) + public Webhooks2Client Webhooks2 => new Webhooks2Client(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -616,7 +619,7 @@ public sealed partial class LabelStudioClient : global::LabelStudio.ILabelStudio /// /// /// - public WorkspacesClient Workspaces => new WorkspacesClient(HttpClient, authorizations: Authorizations) + public WorkspacesClient Workspaces => new WorkspacesClient(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -625,7 +628,7 @@ public sealed partial class LabelStudioClient : global::LabelStudio.ILabelStudio /// /// /// - public Workspaces2Client Workspaces2 => new Workspaces2Client(HttpClient, authorizations: Authorizations) + public Workspaces2Client Workspaces2 => new Workspaces2Client(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -644,11 +647,37 @@ public LabelStudioClient( 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 LabelStudioClient. + /// 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 LabelStudioClient( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::LabelStudio.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::LabelStudio.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/LabelStudio/Generated/LabelStudio.Labels2Client.Create2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Labels2Client.Create2.g.cs index 4e86dfe..1ee78b9 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Labels2Client.Create2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Labels2Client.Create2.g.cs @@ -14,6 +14,7 @@ public partial class Labels2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,6 +52,7 @@ partial void ProcessCreate2ResponseContent( /// /// /// + /// 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 Create2Async( @@ -58,6 +60,7 @@ partial void ProcessCreate2ResponseContent( global::System.Collections.Generic.IList request, string? ordering = default, int? page = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -76,26 +79,47 @@ partial void ProcessCreate2ResponseContent( securityRequirements: s_Create2SecurityRequirements, operationName: "Create2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/labels/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("ordering", ordering) - .AddOptionalParameter("page", page?.ToString()) - ; - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/labels/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("ordering", ordering) + .AddOptionalParameter("page", page?.ToString()) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,120 +129,279 @@ partial void ProcessCreate2ResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } - var __httpRequestContentBody = global::System.Text.Json.JsonSerializer.Serialize(request, request.GetType(), 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); - PrepareCreate2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - ordering: ordering, - page: page, - request: request); + var __httpRequestContentBody = global::System.Text.Json.JsonSerializer.Serialize(request, request.GetType(), JsonSerializerContext); + var __httpRequestContent = new global::System.Net.Http.StringContent( + content: __httpRequestContentBody, + encoding: global::System.Text.Encoding.UTF8, + mediaType: "application/json"); + __httpRequest.Content = __httpRequestContent; + global::LabelStudio.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); + PrepareCreate2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + ordering: ordering, + page: page, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreate2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "\"/api/labels/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "\"/api/labels/\"", + 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); - ProcessCreate2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "\"/api/labels/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.PaginatedLabelCreateList.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.PaginatedLabelCreateList.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessCreate2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "\"/api/labels/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "\"/api/labels/\"", + 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); + ProcessCreate2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.PaginatedLabelCreateList.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.PaginatedLabelCreateList.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.Labels2Client.Delete2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Labels2Client.Delete2.g.cs index 5bbbba4..10daf0e 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Labels2Client.Delete2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Labels2Client.Delete2.g.cs @@ -14,6 +14,7 @@ public partial class Labels2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -40,10 +41,12 @@ partial void ProcessDelete2Response( /// Remove labels from your project without updating the labeling configuration. ///
/// + /// 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 Delete2Async( string id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -58,22 +61,43 @@ partial void ProcessDelete2Response( securityRequirements: s_Delete2SecurityRequirements, operationName: "Delete2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/labels/{id}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/labels/{id}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -83,96 +107,255 @@ partial void ProcessDelete2Response( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDelete2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDelete2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/labels/{id}/\"", + 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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/labels/{id}/\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessDelete2Response( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/labels/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessDelete2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/labels/{id}/\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/labels/{id}/\"", + httpMethod: "DELETE", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.Labels2Client.Get2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Labels2Client.Get2.g.cs index 5ead70c..2fb429a 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Labels2Client.Get2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Labels2Client.Get2.g.cs @@ -14,6 +14,7 @@ public partial class Labels2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -46,10 +47,12 @@ partial void ProcessGet2ResponseContent( /// /// /// + /// 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 Get2Async( string id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -64,22 +67,43 @@ partial void ProcessGet2ResponseContent( securityRequirements: s_Get2SecurityRequirements, operationName: "Get2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/labels/{id}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/labels/{id}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,112 +113,271 @@ partial void ProcessGet2ResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGet2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGet2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGet2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "$\"/api/labels/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "$\"/api/labels/{id}/\"", + 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); - ProcessGet2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "$\"/api/labels/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.Label.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.Label.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGet2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "$\"/api/labels/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "$\"/api/labels/{id}/\"", + 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); + ProcessGet2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.Label.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.Label.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.Labels2Client.List2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Labels2Client.List2.g.cs index 1f220da..638876d 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Labels2Client.List2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Labels2Client.List2.g.cs @@ -14,6 +14,7 @@ public partial class Labels2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -48,11 +49,13 @@ partial void ProcessList2ResponseContent( /// /// /// + /// 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 List2Async( string? ordering = default, int? page = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -68,26 +71,47 @@ partial void ProcessList2ResponseContent( securityRequirements: s_List2SecurityRequirements, operationName: "List2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/labels/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("ordering", ordering) - .AddOptionalParameter("page", page?.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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/labels/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("ordering", ordering) + .AddOptionalParameter("page", page?.ToString()) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -97,113 +121,272 @@ partial void ProcessList2ResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareList2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - ordering: ordering, - page: page); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareList2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + ordering: ordering, + page: page); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessList2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/labels/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/labels/\"", + 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); - ProcessList2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/labels/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.PaginatedLabelList.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.PaginatedLabelList.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessList2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/labels/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/labels/\"", + 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); + ProcessList2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.PaginatedLabelList.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.PaginatedLabelList.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.Labels2Client.Update2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Labels2Client.Update2.g.cs index 7019865..63bc4b2 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Labels2Client.Update2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Labels2Client.Update2.g.cs @@ -14,6 +14,7 @@ public partial class Labels2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -48,12 +49,14 @@ partial void ProcessUpdate2ResponseContent( /// /// /// + /// 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 Update2Async( string id, global::LabelStudio.PatchedLabelRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -71,22 +74,43 @@ partial void ProcessUpdate2ResponseContent( securityRequirements: s_Update2SecurityRequirements, operationName: "Update2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/labels/{id}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/labels/{id}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -96,119 +120,278 @@ partial void ProcessUpdate2ResponseContent( __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); - PrepareUpdate2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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::LabelStudio.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); + PrepareUpdate2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessUpdate2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/labels/{id}/\"", + 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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/labels/{id}/\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessUpdate2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/labels/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.Label.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.Label.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessUpdate2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/labels/{id}/\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/labels/{id}/\"", + httpMethod: "PATCH", + 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); + ProcessUpdate2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.Label.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.Label.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 labels
@@ -234,6 +417,7 @@ partial void ProcessUpdate2ResponseContent( /// /// Label value /// + /// 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 Update2Async( @@ -245,6 +429,7 @@ partial void ProcessUpdate2ResponseContent( int? organization = default, string? title = default, object? value = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.PatchedLabelRequest @@ -261,6 +446,7 @@ partial void ProcessUpdate2ResponseContent( return await Update2Async( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.Labels2Client.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Labels2Client.g.cs index 9ad3885..409c228 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Labels2Client.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Labels2Client.g.cs @@ -30,6 +30,9 @@ public sealed partial class Labels2Client : global::LabelStudio.ILabels2Client, #if DEBUG = true; #endif + + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public Labels2Client( 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 Labels2Client. + /// 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 Labels2Client( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::LabelStudio.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::LabelStudio.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/LabelStudio/Generated/LabelStudio.LabelsClient.Create.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.LabelsClient.Create.g.cs index f4c4911..f0ff6b4 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.LabelsClient.Create.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.LabelsClient.Create.g.cs @@ -14,6 +14,7 @@ public partial class LabelsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,11 +46,13 @@ partial void ProcessCreateResponseContent( /// Create label links to link new custom labels to your project labeling configuration. ///
/// + /// 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 CreateAsync( global::LabelStudio.LabelLinkRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -66,22 +69,43 @@ partial void ProcessCreateResponseContent( securityRequirements: s_CreateSecurityRequirements, operationName: "CreateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/label_links/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/label_links/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,118 +115,277 @@ partial void ProcessCreateResponseContent( __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); - PrepareCreateRequest( - 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::LabelStudio.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); + PrepareCreateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/label_links/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/label_links/\"", + 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); - ProcessCreateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/label_links/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.LabelLink.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.LabelLink.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessCreateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/label_links/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/label_links/\"", + 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); + ProcessCreateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.LabelLink.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.LabelLink.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 label links
@@ -213,12 +396,14 @@ partial void ProcessCreateResponseContent( /// /// /// + /// 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 CreateAsync( string fromName, int label, int project, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.LabelLinkRequest @@ -230,6 +415,7 @@ partial void ProcessCreateResponseContent( return await CreateAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.LabelsClient.Delete.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.LabelsClient.Delete.g.cs index dc8fa01..5c02eb8 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.LabelsClient.Delete.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.LabelsClient.Delete.g.cs @@ -14,6 +14,7 @@ public partial class LabelsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -42,10 +43,12 @@ partial void ProcessDeleteResponse( /// ///
/// + /// 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 DeleteAsync( string id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -60,22 +63,43 @@ partial void ProcessDeleteResponse( securityRequirements: s_DeleteSecurityRequirements, operationName: "DeleteAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/label_links/{id}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/label_links/{id}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -85,96 +109,255 @@ partial void ProcessDeleteResponse( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDeleteRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDeleteRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/label_links/{id}/\"", + 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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/label_links/{id}/\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessDeleteResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/label_links/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessDeleteResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/label_links/{id}/\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/label_links/{id}/\"", + httpMethod: "DELETE", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.LabelsClient.Get.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.LabelsClient.Get.g.cs index 4891256..806638e 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.LabelsClient.Get.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.LabelsClient.Get.g.cs @@ -14,6 +14,7 @@ public partial class LabelsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,10 +46,12 @@ partial void ProcessGetResponseContent( /// Get label links for a specific project configuration. /// /// + /// 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 GetAsync( string id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -63,22 +66,43 @@ partial void ProcessGetResponseContent( securityRequirements: s_GetSecurityRequirements, operationName: "GetAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/label_links/{id}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/label_links/{id}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -88,112 +112,271 @@ partial void ProcessGetResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/label_links/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/label_links/{id}/\"", + 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); - ProcessGetResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/label_links/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.LabelLink.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.LabelLink.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGetResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/label_links/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/label_links/{id}/\"", + 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); + ProcessGetResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.LabelLink.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.LabelLink.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.LabelsClient.List.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.LabelsClient.List.g.cs index 0e5c5b7..9f9d51a 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.LabelsClient.List.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.LabelsClient.List.g.cs @@ -14,6 +14,7 @@ public partial class LabelsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,10 +46,12 @@ partial void ProcessListResponseContent( /// List label links for a specific label and project. /// /// + /// 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 ListAsync( int? page = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -63,25 +66,46 @@ partial void ProcessListResponseContent( securityRequirements: s_ListSecurityRequirements, operationName: "ListAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/label_links/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("page", page?.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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/label_links/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("page", page?.ToString()) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -91,112 +115,271 @@ partial void ProcessListResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareListRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - page: page); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareListRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + page: page); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessListResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/label_links/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/label_links/\"", + 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); - ProcessListResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/label_links/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.PaginatedLabelLinkList.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.PaginatedLabelLinkList.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessListResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/label_links/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/label_links/\"", + 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); + ProcessListResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.PaginatedLabelLinkList.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.PaginatedLabelLinkList.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.LabelsClient.Update.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.LabelsClient.Update.g.cs index 8337416..cdb1547 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.LabelsClient.Update.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.LabelsClient.Update.g.cs @@ -14,6 +14,7 @@ public partial class LabelsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -50,12 +51,14 @@ partial void ProcessUpdateResponseContent( /// /// /// + /// 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 UpdateAsync( string id, global::LabelStudio.PatchedLabelLinkRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -73,22 +76,43 @@ partial void ProcessUpdateResponseContent( securityRequirements: s_UpdateSecurityRequirements, operationName: "UpdateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/label_links/{id}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/label_links/{id}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -98,119 +122,278 @@ partial void ProcessUpdateResponseContent( __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); - PrepareUpdateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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::LabelStudio.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); + PrepareUpdateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessUpdateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/label_links/{id}/\"", + 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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/label_links/{id}/\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessUpdateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/label_links/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.LabelLink.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.LabelLink.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessUpdateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/label_links/{id}/\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/label_links/{id}/\"", + httpMethod: "PATCH", + 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); + ProcessUpdateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.LabelLink.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.LabelLink.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 label link
@@ -224,6 +407,7 @@ partial void ProcessUpdateResponseContent( /// /// /// + /// 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 UpdateAsync( @@ -231,6 +415,7 @@ partial void ProcessUpdateResponseContent( string? fromName = default, int? label = default, int? project = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.PatchedLabelLinkRequest @@ -243,6 +428,7 @@ partial void ProcessUpdateResponseContent( return await UpdateAsync( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.LabelsClient.UpdateMany.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.LabelsClient.UpdateMany.g.cs index b2d5a0a..1c67709 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.LabelsClient.UpdateMany.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.LabelsClient.UpdateMany.g.cs @@ -14,6 +14,7 @@ public partial class LabelsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -38,9 +39,11 @@ partial void ProcessUpdateManyResponse( /// If you want to update the labels in saved annotations, use this endpoint.
/// ///
+ /// 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 UpdateManyAsync( + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -54,22 +57,43 @@ partial void ProcessUpdateManyResponse( securityRequirements: s_UpdateManySecurityRequirements, operationName: "UpdateManyAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/labels/bulk", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/labels/bulk", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -79,95 +103,254 @@ partial void ProcessUpdateManyResponse( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareUpdateManyRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareUpdateManyRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest); + + return __httpRequest; + } - using var __response = await HttpClient.SendAsync( + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateMany", + methodName: "UpdateManyAsync", + pathTemplate: "\"/api/labels/bulk\"", + 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: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateMany", + methodName: "UpdateManyAsync", + pathTemplate: "\"/api/labels/bulk\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessUpdateManyResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateMany", + methodName: "UpdateManyAsync", + pathTemplate: "\"/api/labels/bulk\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessUpdateManyResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateMany", + methodName: "UpdateManyAsync", + pathTemplate: "\"/api/labels/bulk\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateMany", + methodName: "UpdateManyAsync", + pathTemplate: "\"/api/labels/bulk\"", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.LabelsClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.LabelsClient.g.cs index 4cd28af..ea06e32 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.LabelsClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.LabelsClient.g.cs @@ -30,6 +30,9 @@ public sealed partial class LabelsClient : global::LabelStudio.ILabelsClient, gl #if DEBUG = true; #endif + + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public LabelsClient( 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 LabelsClient. + /// 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 LabelsClient( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::LabelStudio.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::LabelStudio.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/LabelStudio/Generated/LabelStudio.LlmClient.ApiLlmOpenaiChatCompletionsCreate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.LlmClient.ApiLlmOpenaiChatCompletionsCreate.g.cs index 57ddd39..a9a5591 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.LlmClient.ApiLlmOpenaiChatCompletionsCreate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.LlmClient.ApiLlmOpenaiChatCompletionsCreate.g.cs @@ -14,6 +14,7 @@ public partial class LlmClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,11 +46,13 @@ partial void ProcessApiLlmOpenaiChatCompletionsCreateResponseContent( /// Proxy requests to OpenAI-compatible chat completions APIs and return the full response payload. Supports multiple providers via model parameter format: "model_name" (defaults to OpenAI), "provider/model_name", or "provider:model_name". Works with providers that offer OpenAI-compatible endpoints. /// /// + /// 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 ApiLlmOpenaiChatCompletionsCreateAsync( global::LabelStudio.ApiLlmOpenaiChatCompletionsCreateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -66,22 +69,43 @@ partial void ProcessApiLlmOpenaiChatCompletionsCreateResponseContent( securityRequirements: s_ApiLlmOpenaiChatCompletionsCreateSecurityRequirements, operationName: "ApiLlmOpenaiChatCompletionsCreateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/llm/openai/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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/llm/openai/chat/completions", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,152 +115,311 @@ partial void ProcessApiLlmOpenaiChatCompletionsCreateResponseContent( __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); - PrepareApiLlmOpenaiChatCompletionsCreateRequest( - 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::LabelStudio.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); + PrepareApiLlmOpenaiChatCompletionsCreateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiLlmOpenaiChatCompletionsCreateResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // - if ((int)__response.StatusCode == 400) + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_400 = null; - global::System.Exception? __exception_400 = null; - string? __value_400 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiLlmOpenaiChatCompletionsCreate", + methodName: "ApiLlmOpenaiChatCompletionsCreateAsync", + pathTemplate: "\"/api/llm/openai/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 { - __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, 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_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiLlmOpenaiChatCompletionsCreate", + methodName: "ApiLlmOpenaiChatCompletionsCreateAsync", + pathTemplate: "\"/api/llm/openai/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; + } - __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiLlmOpenaiChatCompletionsCreate", + methodName: "ApiLlmOpenaiChatCompletionsCreateAsync", + pathTemplate: "\"/api/llm/openai/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::LabelStudio.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::LabelStudio.ApiException( - message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_400, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_400, - ResponseObject = __value_400, - 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); - ProcessApiLlmOpenaiChatCompletionsCreateResponseContent( + response: __response); + ProcessApiLlmOpenaiChatCompletionsCreateResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return __content; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiLlmOpenaiChatCompletionsCreate", + methodName: "ApiLlmOpenaiChatCompletionsCreateAsync", + pathTemplate: "\"/api/llm/openai/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 { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiLlmOpenaiChatCompletionsCreate", + methodName: "ApiLlmOpenaiChatCompletionsCreateAsync", + pathTemplate: "\"/api/llm/openai/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); } - } - else - { - try - { - __response.EnsureSuccessStatusCode(); - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + string? __value_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext); + } + else + { + __content_400 = 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_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::LabelStudio.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseObject = __value_400, + 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); + ProcessApiLlmOpenaiChatCompletionsCreateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return __content; + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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(); + } } /// /// Proxy to OpenAI-Compatible Chat Completions
@@ -249,11 +432,13 @@ partial void ProcessApiLlmOpenaiChatCompletionsCreateResponseContent( /// Model identifier. Can be "model_name" (defaults to OpenAI), "provider/model_name", or "provider:model_name"
/// Example: gpt-4 /// + /// 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 ApiLlmOpenaiChatCompletionsCreateAsync( global::System.Collections.Generic.IList messages, string model, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.ApiLlmOpenaiChatCompletionsCreateRequest @@ -264,6 +449,7 @@ partial void ProcessApiLlmOpenaiChatCompletionsCreateResponseContent( return await ApiLlmOpenaiChatCompletionsCreateAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.LlmClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.LlmClient.g.cs index 2d1a3cc..df3557b 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.LlmClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.LlmClient.g.cs @@ -30,6 +30,9 @@ public sealed partial class LlmClient : global::LabelStudio.ILlmClient, global:: #if DEBUG = true; #endif + + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public LlmClient( 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 LlmClient. + /// 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 LlmClient( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::LabelStudio.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::LabelStudio.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/LabelStudio/Generated/LabelStudio.MlClient.Create.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.MlClient.Create.g.cs index 7c6dd1c..b30c868 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.MlClient.Create.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.MlClient.Create.g.cs @@ -14,6 +14,7 @@ public partial class MlClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -50,11 +51,13 @@ partial void ProcessCreateResponseContent( /// ///
/// + /// 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 CreateAsync( global::LabelStudio.ApiMlCreateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -71,22 +74,43 @@ partial void ProcessCreateResponseContent( securityRequirements: s_CreateSecurityRequirements, operationName: "CreateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/ml/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/ml/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,118 +120,277 @@ partial void ProcessCreateResponseContent( __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::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCreateRequest( - 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); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/ml/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/ml/\"", + 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); - ProcessCreateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/ml/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.MLBackend.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.MLBackend.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessCreateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/ml/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/ml/\"", + 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); + ProcessCreateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.MLBackend.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.MLBackend.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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(); + } } /// /// Add ML Backend
@@ -248,6 +431,7 @@ partial void ProcessCreateResponseContent( /// /// ML backend URL /// + /// 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 CreateAsync( @@ -261,6 +445,7 @@ partial void ProcessCreateResponseContent( int? timeout = default, string? title = default, string? url = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.ApiMlCreateRequest @@ -279,6 +464,7 @@ partial void ProcessCreateResponseContent( return await CreateAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.MlClient.Delete.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.MlClient.Delete.g.cs index 25382bd..179662f 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.MlClient.Delete.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.MlClient.Delete.g.cs @@ -14,6 +14,7 @@ public partial class MlClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -44,10 +45,12 @@ partial void ProcessDeleteResponse( /// ///
/// + /// 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 DeleteAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -62,22 +65,43 @@ partial void ProcessDeleteResponse( securityRequirements: s_DeleteSecurityRequirements, operationName: "DeleteAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/ml/{id}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/ml/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -87,96 +111,255 @@ partial void ProcessDeleteResponse( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDeleteRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDeleteRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/ml/{id}\"", + 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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/ml/{id}\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessDeleteResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/ml/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessDeleteResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/ml/{id}\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/ml/{id}\"", + httpMethod: "DELETE", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.MlClient.Get.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.MlClient.Get.g.cs index ebbc95b..122383d 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.MlClient.Get.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.MlClient.Get.g.cs @@ -14,6 +14,7 @@ public partial class MlClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -49,10 +50,12 @@ partial void ProcessGetResponseContent( /// /// /// + /// 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 GetAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -67,22 +70,43 @@ partial void ProcessGetResponseContent( securityRequirements: s_GetSecurityRequirements, operationName: "GetAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/ml/{id}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/ml/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -92,112 +116,271 @@ partial void ProcessGetResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/ml/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/ml/{id}\"", + 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); - ProcessGetResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/ml/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.MLBackend.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.MLBackend.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGetResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/ml/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/ml/{id}\"", + 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); + ProcessGetResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.MLBackend.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.MLBackend.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.MlClient.List.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.MlClient.List.g.cs index 4ca2e09..2a1458e 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.MlClient.List.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.MlClient.List.g.cs @@ -14,6 +14,7 @@ public partial class MlClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -49,10 +50,12 @@ partial void ProcessListResponseContent( /// /// /// + /// 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> ListAsync( int? project = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -67,25 +70,46 @@ partial void ProcessListResponseContent( securityRequirements: s_ListSecurityRequirements, operationName: "ListAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/ml/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("project", project?.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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/ml/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("project", project?.ToString()) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -95,112 +119,271 @@ partial void ProcessListResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareListRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - project: project); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareListRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + project: project); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessListResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/ml/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/ml/\"", + 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); - ProcessListResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/ml/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessListResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/ml/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/ml/\"", + 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); + ProcessListResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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 + (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.MlClient.ListModelVersions.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.MlClient.ListModelVersions.g.cs index 09a0012..918a16c 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.MlClient.ListModelVersions.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.MlClient.ListModelVersions.g.cs @@ -14,6 +14,7 @@ public partial class MlClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,10 +46,12 @@ partial void ProcessListModelVersionsResponseContent( /// Get available versions of the model. /// /// + /// 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 ListModelVersionsAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -63,22 +66,43 @@ partial void ProcessListModelVersionsResponseContent( securityRequirements: s_ListModelVersionsSecurityRequirements, operationName: "ListModelVersionsAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/ml/{id}/versions", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/ml/{id}/versions", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -88,112 +112,271 @@ partial void ProcessListModelVersionsResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareListModelVersionsRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareListModelVersionsRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessListModelVersionsResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListModelVersions", + methodName: "ListModelVersionsAsync", + pathTemplate: "$\"/api/ml/{id}/versions\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListModelVersions", + methodName: "ListModelVersionsAsync", + pathTemplate: "$\"/api/ml/{id}/versions\"", + 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); - ProcessListModelVersionsResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListModelVersions", + methodName: "ListModelVersionsAsync", + pathTemplate: "$\"/api/ml/{id}/versions\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.ApiMlVersionsRetrieveResponse.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.ApiMlVersionsRetrieveResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessListModelVersionsResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListModelVersions", + methodName: "ListModelVersionsAsync", + pathTemplate: "$\"/api/ml/{id}/versions\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListModelVersions", + methodName: "ListModelVersionsAsync", + pathTemplate: "$\"/api/ml/{id}/versions\"", + 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); + ProcessListModelVersionsResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.ApiMlVersionsRetrieveResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiMlVersionsRetrieveResponse.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.MlClient.PredictAllTasks.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.MlClient.PredictAllTasks.g.cs index 4520db8..892cb05 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.MlClient.PredictAllTasks.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.MlClient.PredictAllTasks.g.cs @@ -14,6 +14,7 @@ public partial class MlClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,11 +52,13 @@ partial void ProcessPredictAllTasksResponse( /// /// /// + /// 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 PredictAllTasksAsync( int id, int? batchSize = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -71,25 +74,46 @@ partial void ProcessPredictAllTasksResponse( securityRequirements: s_PredictAllTasksSecurityRequirements, operationName: "PredictAllTasksAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/ml/{id}/predict", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("batch_size", batchSize?.ToString()) - ; - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/ml/{id}/predict", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("batch_size", batchSize?.ToString()) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,97 +123,256 @@ partial void ProcessPredictAllTasksResponse( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PreparePredictAllTasksRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - batchSize: batchSize, - id: id); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PreparePredictAllTasksRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + batchSize: batchSize, + id: id); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PredictAllTasks", + methodName: "PredictAllTasksAsync", + pathTemplate: "$\"/api/ml/{id}/predict\"", + 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: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PredictAllTasks", + methodName: "PredictAllTasksAsync", + pathTemplate: "$\"/api/ml/{id}/predict\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessPredictAllTasksResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PredictAllTasks", + methodName: "PredictAllTasksAsync", + pathTemplate: "$\"/api/ml/{id}/predict\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessPredictAllTasksResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PredictAllTasks", + methodName: "PredictAllTasksAsync", + pathTemplate: "$\"/api/ml/{id}/predict\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PredictAllTasks", + methodName: "PredictAllTasksAsync", + pathTemplate: "$\"/api/ml/{id}/predict\"", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.MlClient.PredictInteractive.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.MlClient.PredictInteractive.g.cs index 75a12e9..10e8185 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.MlClient.PredictInteractive.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.MlClient.PredictInteractive.g.cs @@ -14,6 +14,7 @@ public partial class MlClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -46,12 +47,14 @@ partial void ProcessPredictInteractiveResponse( /// /// /// + /// 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 PredictInteractiveAsync( int id, global::LabelStudio.MLInteractiveAnnotatingRequestRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -69,22 +72,43 @@ partial void ProcessPredictInteractiveResponse( securityRequirements: s_PredictInteractiveSecurityRequirements, operationName: "PredictInteractiveAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/ml/{id}/interactive-annotating", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/ml/{id}/interactive-annotating", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,103 +118,262 @@ partial void ProcessPredictInteractiveResponse( __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); - PreparePredictInteractiveRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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::LabelStudio.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); + PreparePredictInteractiveRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessPredictInteractiveResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PredictInteractive", + methodName: "PredictInteractiveAsync", + pathTemplate: "$\"/api/ml/{id}/interactive-annotating\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PredictInteractive", + methodName: "PredictInteractiveAsync", + pathTemplate: "$\"/api/ml/{id}/interactive-annotating\"", + 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); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PredictInteractive", + methodName: "PredictInteractiveAsync", + pathTemplate: "$\"/api/ml/{id}/interactive-annotating\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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(); + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessPredictInteractiveResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PredictInteractive", + methodName: "PredictInteractiveAsync", + pathTemplate: "$\"/api/ml/{id}/interactive-annotating\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PredictInteractive", + methodName: "PredictInteractiveAsync", + pathTemplate: "$\"/api/ml/{id}/interactive-annotating\"", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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(); + } } /// /// Request Interactive Annotation
@@ -206,12 +389,14 @@ partial void ProcessPredictInteractiveResponse( /// /// ID of task to annotate /// + /// 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 PredictInteractiveAsync( int id, int task, object? context = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.MLInteractiveAnnotatingRequestRequest @@ -223,6 +408,7 @@ partial void ProcessPredictInteractiveResponse( await PredictInteractiveAsync( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.MlClient.TestPredict.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.MlClient.TestPredict.g.cs index 561eb4e..e6ca79b 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.MlClient.TestPredict.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.MlClient.TestPredict.g.cs @@ -14,6 +14,7 @@ public partial class MlClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -44,12 +45,14 @@ partial void ProcessTestPredictResponse( ///
/// /// + /// 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 TestPredictAsync( int id, global::LabelStudio.MLBackendRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -67,22 +70,43 @@ partial void ProcessTestPredictResponse( securityRequirements: s_TestPredictSecurityRequirements, operationName: "TestPredictAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/ml/{id}/predict/test", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/ml/{id}/predict/test", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -92,141 +116,300 @@ partial void ProcessTestPredictResponse( __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::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareTestPredictRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - request: request); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareTestPredictRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + 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); - ProcessTestPredictResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Predicting error - if ((int)__response.StatusCode == 500) + 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; - string? __value_500 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "TestPredict", + methodName: "TestPredictAsync", + pathTemplate: "$\"/api/ml/{id}/predict/test\"", + 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_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, 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_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "TestPredict", + methodName: "TestPredictAsync", + pathTemplate: "$\"/api/ml/{id}/predict/test\"", + 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_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "TestPredict", + methodName: "TestPredictAsync", + pathTemplate: "$\"/api/ml/{id}/predict/test\"", + 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::LabelStudio.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::LabelStudio.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); - - try - { - __response.EnsureSuccessStatusCode(); - - } - catch (global::System.Exception __ex) + response: __response); + ProcessTestPredictResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "TestPredict", + methodName: "TestPredictAsync", + pathTemplate: "$\"/api/ml/{id}/predict/test\"", + 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 + else { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "TestPredict", + methodName: "TestPredictAsync", + pathTemplate: "$\"/api/ml/{id}/predict/test\"", + 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) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + // Predicting error + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + string? __value_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } + + throw new global::LabelStudio.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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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(); + } } /// /// Test prediction
@@ -279,6 +462,7 @@ partial void ProcessTestPredictResponse( /// /// URL for the machine learning model server /// + /// 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 TestPredictAsync( @@ -297,6 +481,7 @@ partial void ProcessTestPredictResponse( global::LabelStudio.StateEnum? state = default, double? timeout = default, string? title = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.MLBackendRequest @@ -320,6 +505,7 @@ partial void ProcessTestPredictResponse( await TestPredictAsync( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.MlClient.Train.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.MlClient.Train.g.cs index 834c9a4..46a1ccc 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.MlClient.Train.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.MlClient.Train.g.cs @@ -14,6 +14,7 @@ public partial class MlClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -47,12 +48,14 @@ partial void ProcessTrainResponse( ///
/// /// + /// 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 TrainAsync( int id, global::LabelStudio.ApiMlTrainCreateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -70,22 +73,43 @@ partial void ProcessTrainResponse( securityRequirements: s_TrainSecurityRequirements, operationName: "TrainAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/ml/{id}/train", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/ml/{id}/train", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,141 +119,300 @@ partial void ProcessTrainResponse( __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::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareTrainRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - request: request); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareTrainRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + 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); - ProcessTrainResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Training error - if ((int)__response.StatusCode == 500) + 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; - string? __value_500 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Train", + methodName: "TrainAsync", + pathTemplate: "$\"/api/ml/{id}/train\"", + 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_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, 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_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Train", + methodName: "TrainAsync", + pathTemplate: "$\"/api/ml/{id}/train\"", + 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_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Train", + methodName: "TrainAsync", + pathTemplate: "$\"/api/ml/{id}/train\"", + 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::LabelStudio.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::LabelStudio.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); - - try - { - __response.EnsureSuccessStatusCode(); - - } - catch (global::System.Exception __ex) + response: __response); + ProcessTrainResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Train", + methodName: "TrainAsync", + pathTemplate: "$\"/api/ml/{id}/train\"", + 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 + else { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Train", + methodName: "TrainAsync", + pathTemplate: "$\"/api/ml/{id}/train\"", + 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) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + // Training error + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + string? __value_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } + + throw new global::LabelStudio.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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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(); + } } /// /// Train
@@ -243,11 +426,13 @@ partial void ProcessTrainResponse( /// /// Whether to include ground truth annotations in training /// + /// 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 TrainAsync( int id, bool? useGroundTruth = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.ApiMlTrainCreateRequest @@ -258,6 +443,7 @@ partial void ProcessTrainResponse( await TrainAsync( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.MlClient.Update.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.MlClient.Update.g.cs index fb0b9a4..bab0c30 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.MlClient.Update.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.MlClient.Update.g.cs @@ -14,6 +14,7 @@ public partial class MlClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -52,12 +53,14 @@ partial void ProcessUpdateResponseContent( ///
/// /// + /// 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 UpdateAsync( int id, global::LabelStudio.ApiMlPartialUpdateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -75,22 +78,43 @@ partial void ProcessUpdateResponseContent( securityRequirements: s_UpdateSecurityRequirements, operationName: "UpdateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/ml/{id}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/ml/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -100,119 +124,278 @@ partial void ProcessUpdateResponseContent( __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); - PrepareUpdateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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::LabelStudio.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); + PrepareUpdateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessUpdateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/ml/{id}\"", + 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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/ml/{id}\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessUpdateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/ml/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.MLBackend.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.MLBackend.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessUpdateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/ml/{id}\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/ml/{id}\"", + httpMethod: "PATCH", + 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); + ProcessUpdateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.MLBackend.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.MLBackend.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 ML Backend
@@ -253,6 +436,7 @@ partial void ProcessUpdateResponseContent( /// /// ML backend URL /// + /// 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 UpdateAsync( @@ -267,6 +451,7 @@ partial void ProcessUpdateResponseContent( int? timeout = default, string? title = default, string? url = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.ApiMlPartialUpdateRequest @@ -286,6 +471,7 @@ partial void ProcessUpdateResponseContent( return await UpdateAsync( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.MlClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.MlClient.g.cs index 15c59c2..f573cef 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.MlClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.MlClient.g.cs @@ -30,6 +30,9 @@ public sealed partial class MlClient : global::LabelStudio.IMlClient, global::Sy #if DEBUG = true; #endif + + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public MlClient( 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 MlClient. + /// 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 MlClient( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::LabelStudio.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::LabelStudio.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ModelProviderConnectionClient.ApiModelProviderConnectionsUpdate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ModelProviderConnectionClient.ApiModelProviderConnectionsUpdate.g.cs index 718cf24..336427b 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ModelProviderConnectionClient.ApiModelProviderConnectionsUpdate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ModelProviderConnectionClient.ApiModelProviderConnectionsUpdate.g.cs @@ -14,6 +14,7 @@ public partial class ModelProviderConnectionClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -54,12 +55,14 @@ partial void ProcessApiModelProviderConnectionsUpdateResponseContent( ///
/// /// + /// 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 ApiModelProviderConnectionsUpdateAsync( string id, global::LabelStudio.ModelProviderConnectionRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -77,22 +80,43 @@ partial void ProcessApiModelProviderConnectionsUpdateResponseContent( securityRequirements: s_ApiModelProviderConnectionsUpdateSecurityRequirements, operationName: "ApiModelProviderConnectionsUpdateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/model-provider-connections/{id}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/model-provider-connections/{id}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -102,119 +126,278 @@ partial void ProcessApiModelProviderConnectionsUpdateResponseContent( __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); - PrepareApiModelProviderConnectionsUpdateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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::LabelStudio.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); + PrepareApiModelProviderConnectionsUpdateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiModelProviderConnectionsUpdateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiModelProviderConnectionsUpdate", + methodName: "ApiModelProviderConnectionsUpdateAsync", + pathTemplate: "$\"/api/model-provider-connections/{id}/\"", + 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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiModelProviderConnectionsUpdate", + methodName: "ApiModelProviderConnectionsUpdateAsync", + pathTemplate: "$\"/api/model-provider-connections/{id}/\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessApiModelProviderConnectionsUpdateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiModelProviderConnectionsUpdate", + methodName: "ApiModelProviderConnectionsUpdateAsync", + pathTemplate: "$\"/api/model-provider-connections/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.ModelProviderConnection.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.ModelProviderConnection.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessApiModelProviderConnectionsUpdateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiModelProviderConnectionsUpdate", + methodName: "ApiModelProviderConnectionsUpdateAsync", + pathTemplate: "$\"/api/model-provider-connections/{id}/\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiModelProviderConnectionsUpdate", + methodName: "ApiModelProviderConnectionsUpdateAsync", + pathTemplate: "$\"/api/model-provider-connections/{id}/\"", + httpMethod: "PUT", + 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); + ProcessApiModelProviderConnectionsUpdateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.ModelProviderConnection.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ModelProviderConnection.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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(); + } } /// /// ✨ Put model provider connection
@@ -274,6 +457,7 @@ partial void ProcessApiModelProviderConnectionsUpdateResponseContent( /// * `User` - User
/// * `Model` - Model /// + /// 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 ApiModelProviderConnectionsUpdateAsync( @@ -290,6 +474,7 @@ partial void ProcessApiModelProviderConnectionsUpdateResponseContent( bool? isInternal = default, global::LabelStudio.ProviderEnum? provider = default, global::LabelStudio.ScopeEnum? scope = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.ModelProviderConnectionRequest @@ -311,6 +496,7 @@ partial void ProcessApiModelProviderConnectionsUpdateResponseContent( return await ApiModelProviderConnectionsUpdateAsync( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ModelProviderConnectionClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ModelProviderConnectionClient.g.cs index c866a7d..a174b76 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ModelProviderConnectionClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ModelProviderConnectionClient.g.cs @@ -30,6 +30,9 @@ public sealed partial class ModelProviderConnectionClient : global::LabelStudio. #if DEBUG = true; #endif + + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public ModelProviderConnectionClient( 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 ModelProviderConnectionClient. + /// 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 ModelProviderConnectionClient( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::LabelStudio.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::LabelStudio.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ModelProvidersClient.Create.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ModelProvidersClient.Create.g.cs index 7ff9c5d..d56fb72 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ModelProvidersClient.Create.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ModelProvidersClient.Create.g.cs @@ -14,6 +14,7 @@ public partial class ModelProvidersClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,11 +52,13 @@ partial void ProcessCreateResponseContent( /// Create a new model provider connection. ///
/// + /// 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 CreateAsync( global::LabelStudio.ModelProviderConnectionRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -72,22 +75,43 @@ partial void ProcessCreateResponseContent( securityRequirements: s_CreateSecurityRequirements, operationName: "CreateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/model-provider-connections/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/model-provider-connections/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -97,118 +121,277 @@ partial void ProcessCreateResponseContent( __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::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCreateRequest( - 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); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/model-provider-connections/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/model-provider-connections/\"", + 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); - ProcessCreateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/model-provider-connections/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.ModelProviderConnection.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.ModelProviderConnection.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessCreateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/model-provider-connections/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/model-provider-connections/\"", + 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); + ProcessCreateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.ModelProviderConnection.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ModelProviderConnection.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 model provider connection
@@ -267,6 +450,7 @@ partial void ProcessCreateResponseContent( /// * `User` - User
/// * `Model` - Model /// + /// 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 CreateAsync( @@ -282,6 +466,7 @@ partial void ProcessCreateResponseContent( bool? isInternal = default, global::LabelStudio.ProviderEnum? provider = default, global::LabelStudio.ScopeEnum? scope = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.ModelProviderConnectionRequest @@ -302,6 +487,7 @@ partial void ProcessCreateResponseContent( return await CreateAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ModelProvidersClient.Delete.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ModelProvidersClient.Delete.g.cs index 1d0c2d9..8ec4df5 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ModelProvidersClient.Delete.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ModelProvidersClient.Delete.g.cs @@ -14,6 +14,7 @@ public partial class ModelProvidersClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -46,10 +47,12 @@ partial void ProcessDeleteResponse( /// Delete a model provider connection by ID ///
/// + /// 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 DeleteAsync( string id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -64,22 +67,43 @@ partial void ProcessDeleteResponse( securityRequirements: s_DeleteSecurityRequirements, operationName: "DeleteAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/model-provider-connections/{id}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/model-provider-connections/{id}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -89,96 +113,255 @@ partial void ProcessDeleteResponse( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDeleteRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDeleteRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/model-provider-connections/{id}/\"", + 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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/model-provider-connections/{id}/\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessDeleteResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/model-provider-connections/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessDeleteResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/model-provider-connections/{id}/\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/model-provider-connections/{id}/\"", + httpMethod: "DELETE", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.ModelProvidersClient.Get.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ModelProvidersClient.Get.g.cs index 2e3e0bd..6da539a 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ModelProvidersClient.Get.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ModelProvidersClient.Get.g.cs @@ -14,6 +14,7 @@ public partial class ModelProvidersClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,10 +52,12 @@ partial void ProcessGetResponseContent( /// Retrieve a specific model provider connection. /// /// + /// 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 GetAsync( string id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -69,22 +72,43 @@ partial void ProcessGetResponseContent( securityRequirements: s_GetSecurityRequirements, operationName: "GetAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/model-provider-connections/{id}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/model-provider-connections/{id}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,112 +118,271 @@ partial void ProcessGetResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/model-provider-connections/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/model-provider-connections/{id}/\"", + 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); - ProcessGetResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/model-provider-connections/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.ModelProviderConnection.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.ModelProviderConnection.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGetResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/model-provider-connections/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/model-provider-connections/{id}/\"", + 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); + ProcessGetResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.ModelProviderConnection.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ModelProviderConnection.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.ModelProvidersClient.List.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ModelProvidersClient.List.g.cs index 8eff5a5..72f8631 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ModelProvidersClient.List.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ModelProvidersClient.List.g.cs @@ -14,6 +14,7 @@ public partial class ModelProvidersClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,10 +52,12 @@ partial void ProcessListResponseContent( /// List all model provider connections. /// /// + /// 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> ListAsync( string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -69,25 +72,46 @@ partial void ProcessListResponseContent( securityRequirements: s_ListSecurityRequirements, operationName: "ListAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/model-provider-connections/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("ordering", ordering) - ; - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/model-provider-connections/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("ordering", ordering) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -97,112 +121,271 @@ partial void ProcessListResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareListRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - ordering: ordering); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareListRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + ordering: ordering); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessListResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/model-provider-connections/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/model-provider-connections/\"", + 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); - ProcessListResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/model-provider-connections/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessListResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/model-provider-connections/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/model-provider-connections/\"", + 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); + ProcessListResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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 + (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.ModelProvidersClient.ListModelProviderChoices.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ModelProvidersClient.ListModelProviderChoices.g.cs index 0954bbc..59eadc9 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ModelProvidersClient.ListModelProviderChoices.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ModelProvidersClient.ListModelProviderChoices.g.cs @@ -14,6 +14,7 @@ public partial class ModelProvidersClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -48,9 +49,11 @@ partial void ProcessListModelProviderChoicesResponseContent( /// </Card>
/// List all possible model provider choices /// + /// 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 ListModelProviderChoicesAsync( + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -64,22 +67,43 @@ partial void ProcessListModelProviderChoicesResponseContent( securityRequirements: s_ListModelProviderChoicesSecurityRequirements, operationName: "ListModelProviderChoicesAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/model-provider-connections/provider-choices", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/model-provider-connections/provider-choices", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,111 +113,270 @@ partial void ProcessListModelProviderChoicesResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareListModelProviderChoicesRequest( - 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); + PrepareListModelProviderChoicesRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessListModelProviderChoicesResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListModelProviderChoices", + methodName: "ListModelProviderChoicesAsync", + pathTemplate: "\"/api/model-provider-connections/provider-choices\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListModelProviderChoices", + methodName: "ListModelProviderChoicesAsync", + pathTemplate: "\"/api/model-provider-connections/provider-choices\"", + 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); - ProcessListModelProviderChoicesResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListModelProviderChoices", + methodName: "ListModelProviderChoicesAsync", + pathTemplate: "\"/api/model-provider-connections/provider-choices\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.ApiModelProviderConnectionsProviderChoicesRetrieveResponse.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.ApiModelProviderConnectionsProviderChoicesRetrieveResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessListModelProviderChoicesResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListModelProviderChoices", + methodName: "ListModelProviderChoicesAsync", + pathTemplate: "\"/api/model-provider-connections/provider-choices\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListModelProviderChoices", + methodName: "ListModelProviderChoicesAsync", + pathTemplate: "\"/api/model-provider-connections/provider-choices\"", + 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); + ProcessListModelProviderChoicesResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.ApiModelProviderConnectionsProviderChoicesRetrieveResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiModelProviderConnectionsProviderChoicesRetrieveResponse.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.ModelProvidersClient.Update.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ModelProvidersClient.Update.g.cs index 9ab7e3e..dd7b6e7 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ModelProvidersClient.Update.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ModelProvidersClient.Update.g.cs @@ -14,6 +14,7 @@ public partial class ModelProvidersClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -54,12 +55,14 @@ partial void ProcessUpdateResponseContent( /// /// /// + /// 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 UpdateAsync( string id, global::LabelStudio.PatchedModelProviderConnectionRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -77,22 +80,43 @@ partial void ProcessUpdateResponseContent( securityRequirements: s_UpdateSecurityRequirements, operationName: "UpdateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/model-provider-connections/{id}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/model-provider-connections/{id}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -102,119 +126,278 @@ partial void ProcessUpdateResponseContent( __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); - PrepareUpdateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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::LabelStudio.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); + PrepareUpdateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessUpdateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/model-provider-connections/{id}/\"", + 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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/model-provider-connections/{id}/\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessUpdateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/model-provider-connections/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.ModelProviderConnection.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.ModelProviderConnection.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessUpdateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/model-provider-connections/{id}/\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/model-provider-connections/{id}/\"", + httpMethod: "PATCH", + 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); + ProcessUpdateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.ModelProviderConnection.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ModelProviderConnection.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 model provider connection
@@ -274,6 +457,7 @@ partial void ProcessUpdateResponseContent( /// * `User` - User
/// * `Model` - Model /// + /// 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 UpdateAsync( @@ -290,6 +474,7 @@ partial void ProcessUpdateResponseContent( bool? isInternal = default, global::LabelStudio.ProviderEnum? provider = default, global::LabelStudio.ScopeEnum? scope = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.PatchedModelProviderConnectionRequest @@ -311,6 +496,7 @@ partial void ProcessUpdateResponseContent( return await UpdateAsync( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ModelProvidersClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ModelProvidersClient.g.cs index 9777670..4b735be 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ModelProvidersClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ModelProvidersClient.g.cs @@ -30,6 +30,9 @@ public sealed partial class ModelProvidersClient : global::LabelStudio.IModelPro #if DEBUG = true; #endif + + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public ModelProvidersClient( 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 ModelProvidersClient. + /// 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 ModelProvidersClient( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::LabelStudio.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::LabelStudio.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/LabelStudio/Generated/LabelStudio.OptionsSupport.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.OptionsSupport.g.cs new file mode 100644 index 0000000..3e3afa9 --- /dev/null +++ b/src/libs/LabelStudio/Generated/LabelStudio.OptionsSupport.g.cs @@ -0,0 +1,460 @@ + +#nullable enable + +namespace LabelStudio +{ + /// + /// 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::LabelStudio.AutoSDKRetryOptions Retry { get; set; } = new global::LabelStudio.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::LabelStudio.AutoSDKClientOptions AddHook( + global::LabelStudio.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::LabelStudio.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::LabelStudio.AutoSDKHookContext context); + + /// + /// Runs after a successful HTTP response is received. + /// + /// + global::System.Threading.Tasks.Task OnAfterSuccessAsync( + global::LabelStudio.AutoSDKHookContext context); + + /// + /// Runs after an error response or transport failure is observed. + /// + /// + global::System.Threading.Tasks.Task OnAfterErrorAsync( + global::LabelStudio.AutoSDKHookContext context); + } + + /// + /// Convenience base type for request hooks with no-op defaults. + /// + public abstract class AutoSDKHook : global::LabelStudio.IAutoSDKHook + { + /// + public virtual global::System.Threading.Tasks.Task OnBeforeRequestAsync( + global::LabelStudio.AutoSDKHookContext context) + { + return global::System.Threading.Tasks.Task.CompletedTask; + } + + /// + public virtual global::System.Threading.Tasks.Task OnAfterSuccessAsync( + global::LabelStudio.AutoSDKHookContext context) + { + return global::System.Threading.Tasks.Task.CompletedTask; + } + + /// + public virtual global::System.Threading.Tasks.Task OnAfterErrorAsync( + global::LabelStudio.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::LabelStudio.AutoSDKClientOptions ClientOptions { get; set; } = null!; + + /// + /// The per-request runtime options. + /// + public global::LabelStudio.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::LabelStudio.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::LabelStudio.AutoSDKClientOptions clientOptions, + global::LabelStudio.AutoSDKRequestOptions? requestOptions, + int attempt, + int maxAttempts, + bool willRetry, + global::System.Threading.CancellationToken cancellationToken) + { + return new global::LabelStudio.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::LabelStudio.AutoSDKClientOptions clientOptions, + global::LabelStudio.AutoSDKHookContext context) + { + return InvokeHooksAsync(clientOptions, static (hook, hookContext) => hook.OnBeforeRequestAsync(hookContext), context); + } + + internal static global::System.Threading.Tasks.Task OnAfterSuccessAsync( + global::LabelStudio.AutoSDKClientOptions clientOptions, + global::LabelStudio.AutoSDKHookContext context) + { + return InvokeHooksAsync(clientOptions, static (hook, hookContext) => hook.OnAfterSuccessAsync(hookContext), context); + } + + internal static global::System.Threading.Tasks.Task OnAfterErrorAsync( + global::LabelStudio.AutoSDKClientOptions clientOptions, + global::LabelStudio.AutoSDKHookContext context) + { + return InvokeHooksAsync(clientOptions, static (hook, hookContext) => hook.OnAfterErrorAsync(hookContext), context); + } + + internal static bool GetReadResponseAsString( + global::LabelStudio.AutoSDKClientOptions clientOptions, + global::LabelStudio.AutoSDKRequestOptions? requestOptions, + bool fallbackValue) + { + return requestOptions?.ReadResponseAsString ?? + clientOptions.ReadResponseAsString ?? + fallbackValue; + } + + internal static global::System.Threading.CancellationTokenSource? CreateTimeoutCancellationTokenSource( + global::LabelStudio.AutoSDKClientOptions clientOptions, + global::LabelStudio.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::LabelStudio.AutoSDKClientOptions clientOptions, + global::LabelStudio.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::LabelStudio.AutoSDKClientOptions clientOptions, + global::LabelStudio.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::LabelStudio.AutoSDKClientOptions clientOptions, + global::System.Func callback, + global::LabelStudio.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/LabelStudio/Generated/LabelStudio.Organizations2Client.Get.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Organizations2Client.Get.g.cs index a01f521..ce53e03 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Organizations2Client.Get.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Organizations2Client.Get.g.cs @@ -14,6 +14,7 @@ public partial class Organizations2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,10 +46,12 @@ partial void ProcessGetResponseContent( /// Retrieve the settings for a specific organization by ID. ///
/// + /// 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 GetAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -63,22 +66,43 @@ partial void ProcessGetResponseContent( securityRequirements: s_GetSecurityRequirements, operationName: "GetAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/organizations/{id}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/organizations/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -88,112 +112,271 @@ partial void ProcessGetResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/organizations/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/organizations/{id}\"", + 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); - ProcessGetResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/organizations/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.LseOrganization.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.LseOrganization.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGetResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/organizations/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/organizations/{id}\"", + 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); + ProcessGetResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.LseOrganization.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.LseOrganization.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.Organizations2Client.List.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Organizations2Client.List.g.cs index d239115..f3fe17a 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Organizations2Client.List.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Organizations2Client.List.g.cs @@ -14,6 +14,7 @@ public partial class Organizations2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -46,10 +47,12 @@ partial void ProcessListResponseContent( /// /// /// + /// 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> ListAsync( string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -64,25 +67,46 @@ partial void ProcessListResponseContent( securityRequirements: s_ListSecurityRequirements, operationName: "ListAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/organizations/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("ordering", ordering) - ; - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/organizations/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("ordering", ordering) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -92,112 +116,271 @@ partial void ProcessListResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareListRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - ordering: ordering); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareListRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + ordering: ordering); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessListResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/organizations/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/organizations/\"", + 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); - ProcessListResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/organizations/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessListResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/organizations/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/organizations/\"", + 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); + ProcessListResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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 + (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.Organizations2Client.ResetToken.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Organizations2Client.ResetToken.g.cs index b757011..dbf6d0c 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Organizations2Client.ResetToken.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Organizations2Client.ResetToken.g.cs @@ -14,6 +14,7 @@ public partial class Organizations2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -42,9 +43,11 @@ partial void ProcessResetTokenResponseContent( /// Reset organization token
/// Reset the token used in the invitation link to invite someone to an 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 ResetTokenAsync( + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -58,22 +61,43 @@ partial void ProcessResetTokenResponseContent( securityRequirements: s_ResetTokenSecurityRequirements, operationName: "ResetTokenAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/invite/reset-token", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/invite/reset-token", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -83,111 +107,270 @@ partial void ProcessResetTokenResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareResetTokenRequest( - 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); + PrepareResetTokenRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessResetTokenResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ResetToken", + methodName: "ResetTokenAsync", + pathTemplate: "\"/api/invite/reset-token\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ResetToken", + methodName: "ResetTokenAsync", + pathTemplate: "\"/api/invite/reset-token\"", + 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); - ProcessResetTokenResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ResetToken", + methodName: "ResetTokenAsync", + pathTemplate: "\"/api/invite/reset-token\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.OrganizationInvite.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.OrganizationInvite.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessResetTokenResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ResetToken", + methodName: "ResetTokenAsync", + pathTemplate: "\"/api/invite/reset-token\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ResetToken", + methodName: "ResetTokenAsync", + pathTemplate: "\"/api/invite/reset-token\"", + 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); + ProcessResetTokenResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.OrganizationInvite.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.OrganizationInvite.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.Organizations2Client.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Organizations2Client.g.cs index db0e626..0c5e273 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Organizations2Client.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Organizations2Client.g.cs @@ -30,6 +30,9 @@ public sealed partial class Organizations2Client : global::LabelStudio.IOrganiza #if DEBUG = true; #endif + + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public Organizations2Client( 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 Organizations2Client. + /// 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 Organizations2Client( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::LabelStudio.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::LabelStudio.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.Assign.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.Assign.g.cs index 5797cc1..99e05f1 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.Assign.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.Assign.g.cs @@ -14,6 +14,7 @@ public partial class OrganizationsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -75,6 +76,7 @@ partial void ProcessAssignResponseContent( /// /// /// + /// 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 AssignAsync( @@ -88,6 +90,7 @@ partial void ProcessAssignResponseContent( string? tags = default, string? userLastActivityGte = default, string? userLastActivityLte = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -112,31 +115,52 @@ partial void ProcessAssignResponseContent( securityRequirements: s_AssignSecurityRequirements, operationName: "AssignAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/organizations/{id}/member-tags/assignments", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("exclude_project_id", excludeProjectId?.ToString()) - .AddOptionalParameter("exclude_workspace_id", excludeWorkspaceId?.ToString()) - .AddOptionalParameter("is_deleted", isDeleted?.ToString().ToLowerInvariant()) - .AddOptionalParameter("role", role) - .AddOptionalParameter("tags", tags) - .AddOptionalParameter("user__last_activity__gte", userLastActivityGte) - .AddOptionalParameter("user__last_activity__lte", userLastActivityLte) - ; - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/organizations/{id}/member-tags/assignments", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("exclude_project_id", excludeProjectId?.ToString()) + .AddOptionalParameter("exclude_workspace_id", excludeWorkspaceId?.ToString()) + .AddOptionalParameter("is_deleted", isDeleted?.ToString().ToLowerInvariant()) + .AddOptionalParameter("role", role) + .AddOptionalParameter("tags", tags) + .AddOptionalParameter("user__last_activity__gte", userLastActivityGte) + .AddOptionalParameter("user__last_activity__lte", userLastActivityLte) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -146,192 +170,351 @@ partial void ProcessAssignResponseContent( __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); - PrepareAssignRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - excludeProjectId: excludeProjectId, - excludeWorkspaceId: excludeWorkspaceId, - id: id, - isDeleted: isDeleted, - role: role, - tags: tags, - userLastActivityGte: userLastActivityGte, - userLastActivityLte: userLastActivityLte, - 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::LabelStudio.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); + PrepareAssignRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + excludeProjectId: excludeProjectId, + excludeWorkspaceId: excludeWorkspaceId, + id: id, + isDeleted: isDeleted, + role: role, + tags: tags, + userLastActivityGte: userLastActivityGte, + userLastActivityLte: userLastActivityLte, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessAssignResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // - if ((int)__response.StatusCode == 400) + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_400 = null; - global::System.Exception? __exception_400 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Assign", + methodName: "AssignAsync", + pathTemplate: "$\"/api/organizations/{id}/member-tags/assignments\"", + 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_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + __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_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - } - } - catch (global::System.Exception __ex) - { - __exception_400 = __ex; - } + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Assign", + methodName: "AssignAsync", + pathTemplate: "$\"/api/organizations/{id}/member-tags/assignments\"", + 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; + } - throw new global::LabelStudio.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 == 403) - { - string? __content_403 = null; - global::System.Exception? __exception_403 = null; - try - { - if (ReadResponseAsString) - { - __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else + + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Assign", + methodName: "AssignAsync", + pathTemplate: "$\"/api/organizations/{id}/member-tags/assignments\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_403 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::LabelStudio.ApiException( - message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_403, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_403, - 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); - ProcessAssignResponseContent( + response: __response); + ProcessAssignResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::LabelStudio.ApiOrganizationsMemberTagsAssignmentsCreateResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Assign", + methodName: "AssignAsync", + pathTemplate: "$\"/api/organizations/{id}/member-tags/assignments\"", + 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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Assign", + methodName: "AssignAsync", + pathTemplate: "$\"/api/organizations/{id}/member-tags/assignments\"", + 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); + // + 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; + } - return - await global::LabelStudio.ApiOrganizationsMemberTagsAssignmentsCreateResponse.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) - { - } + throw new global::LabelStudio.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 == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } + + throw new global::LabelStudio.ApiException( + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + statusCode: __response.StatusCode) + { + ResponseBody = __content_403, + 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); + ProcessAssignResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.ApiOrganizationsMemberTagsAssignmentsCreateResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiOrganizationsMemberTagsAssignmentsCreateResponse.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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(); + } } /// /// ✨ Bulk assign tags to organization members
@@ -367,6 +550,7 @@ partial void ProcessAssignResponseContent( /// /// List of tag IDs to assign. /// + /// 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 AssignAsync( @@ -383,6 +567,7 @@ partial void ProcessAssignResponseContent( global::System.Collections.Generic.IList? included = default, bool? overwrite = default, global::System.Collections.Generic.IList? requestTags = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.BulkOrganizationMemberTagAssignmentRequest @@ -404,6 +589,7 @@ partial void ProcessAssignResponseContent( userLastActivityGte: userLastActivityGte, userLastActivityLte: userLastActivityLte, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.Create.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.Create.g.cs index b069757..b7f8606 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.Create.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.Create.g.cs @@ -14,6 +14,7 @@ public partial class OrganizationsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -54,12 +55,14 @@ partial void ProcessCreateResponseContent( ///
/// /// + /// 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 CreateAsync( int id, global::LabelStudio.OrganizationMemberTagRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -77,22 +80,43 @@ partial void ProcessCreateResponseContent( securityRequirements: s_CreateSecurityRequirements, operationName: "CreateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/organizations/{id}/member-tags", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/organizations/{id}/member-tags", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -102,185 +126,344 @@ partial void ProcessCreateResponseContent( __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); - PrepareCreateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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::LabelStudio.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); + PrepareCreateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreateResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // - if ((int)__response.StatusCode == 400) + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_400 = null; - global::System.Exception? __exception_400 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "$\"/api/organizations/{id}/member-tags\"", + 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_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + __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_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - } - } - catch (global::System.Exception __ex) - { - __exception_400 = __ex; - } + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "$\"/api/organizations/{id}/member-tags\"", + 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; + } - throw new global::LabelStudio.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 == 403) - { - string? __content_403 = null; - global::System.Exception? __exception_403 = null; - try - { - if (ReadResponseAsString) - { - __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else + + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "$\"/api/organizations/{id}/member-tags\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_403 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::LabelStudio.ApiException( - message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_403, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_403, - 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); - ProcessCreateResponseContent( + response: __response); + ProcessCreateResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::LabelStudio.OrganizationMemberTag.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "$\"/api/organizations/{id}/member-tags\"", + 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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "$\"/api/organizations/{id}/member-tags\"", + 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); + // + 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; + } - return - await global::LabelStudio.OrganizationMemberTag.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) - { - } + throw new global::LabelStudio.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 == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } + + throw new global::LabelStudio.ApiException( + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + statusCode: __response.StatusCode) + { + ResponseBody = __content_403, + 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); + ProcessCreateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.OrganizationMemberTag.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.OrganizationMemberTag.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 organization member tag
@@ -296,11 +479,13 @@ partial void ProcessCreateResponseContent( /// /// Label /// + /// 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 CreateAsync( int id, string label, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.OrganizationMemberTagRequest @@ -311,6 +496,7 @@ partial void ProcessCreateResponseContent( return await CreateAsync( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.Create2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.Create2.g.cs index f7e3efa..87644cf 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.Create2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.Create2.g.cs @@ -14,6 +14,7 @@ public partial class OrganizationsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -54,12 +55,14 @@ partial void ProcessCreate2ResponseContent( ///
/// /// + /// 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 Create2Async( int id, global::LabelStudio.OrganizationPermissionRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -77,22 +80,43 @@ partial void ProcessCreate2ResponseContent( securityRequirements: s_Create2SecurityRequirements, operationName: "Create2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/organizations/{id}/permissions", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/organizations/{id}/permissions", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -102,185 +126,344 @@ partial void ProcessCreate2ResponseContent( __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); - PrepareCreate2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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::LabelStudio.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); + PrepareCreate2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreate2Response( - httpClient: HttpClient, - httpResponseMessage: __response); - // - if ((int)__response.StatusCode == 400) + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_400 = null; - global::System.Exception? __exception_400 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "$\"/api/organizations/{id}/permissions\"", + 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_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + __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_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - } - } - catch (global::System.Exception __ex) - { - __exception_400 = __ex; - } + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "$\"/api/organizations/{id}/permissions\"", + 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; + } - throw new global::LabelStudio.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 == 403) - { - string? __content_403 = null; - global::System.Exception? __exception_403 = null; - try - { - if (ReadResponseAsString) - { - __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else + + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "$\"/api/organizations/{id}/permissions\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_403 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::LabelStudio.ApiException( - message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_403, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_403, - 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); - ProcessCreate2ResponseContent( + response: __response); + ProcessCreate2Response( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::LabelStudio.OrganizationPermission.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "$\"/api/organizations/{id}/permissions\"", + 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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "$\"/api/organizations/{id}/permissions\"", + 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); + // + 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; + } - return - await global::LabelStudio.OrganizationPermission.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) - { - } + throw new global::LabelStudio.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 == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } + + throw new global::LabelStudio.ApiException( + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + statusCode: __response.StatusCode) + { + ResponseBody = __content_403, + 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); + ProcessCreate2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.OrganizationPermission.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.OrganizationPermission.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 organization permission override
@@ -297,12 +480,14 @@ partial void ProcessCreate2ResponseContent( /// /// Organization roles /// + /// 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 Create2Async( int id, string permission, global::System.Collections.Generic.IList? roles = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.OrganizationPermissionRequest @@ -314,6 +499,7 @@ partial void ProcessCreate2ResponseContent( return await Create2Async( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.Delete.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.Delete.g.cs index b13d80f..951f34b 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.Delete.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.Delete.g.cs @@ -14,6 +14,7 @@ public partial class OrganizationsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -54,11 +55,13 @@ partial void ProcessDeleteResponseContent( ///
/// /// + /// 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 DeleteAsync( int id, string? ids = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -74,25 +77,46 @@ partial void ProcessDeleteResponseContent( securityRequirements: s_DeleteSecurityRequirements, operationName: "DeleteAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/organizations/{id}/member-tags/bulk", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("ids", ids) - ; - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/organizations/{id}/member-tags/bulk", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("ids", ids) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,179 +126,338 @@ partial void ProcessDeleteResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDeleteRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - ids: ids); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDeleteRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + ids: ids); - 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); - ProcessDeleteResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // - if ((int)__response.StatusCode == 400) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_400 = null; - global::System.Exception? __exception_400 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/organizations/{id}/member-tags/bulk\"", + 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_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + __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_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - } - } - catch (global::System.Exception __ex) - { - __exception_400 = __ex; - } + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/organizations/{id}/member-tags/bulk\"", + 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; + } - throw new global::LabelStudio.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 == 403) - { - string? __content_403 = null; - global::System.Exception? __exception_403 = null; - try - { - if (ReadResponseAsString) - { - __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else + + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/organizations/{id}/member-tags/bulk\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_403 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::LabelStudio.ApiException( - message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_403, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_403, - 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); - ProcessDeleteResponseContent( + response: __response); + ProcessDeleteResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::LabelStudio.ApiOrganizationsMemberTagsBulkDestroyResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/organizations/{id}/member-tags/bulk\"", + 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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/organizations/{id}/member-tags/bulk\"", + 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); + // + 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; + } - return - await global::LabelStudio.ApiOrganizationsMemberTagsBulkDestroyResponse.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) - { - } + throw new global::LabelStudio.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 == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } + + throw new global::LabelStudio.ApiException( + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + statusCode: __response.StatusCode) + { + ResponseBody = __content_403, + 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); + ProcessDeleteResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.ApiOrganizationsMemberTagsBulkDestroyResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiOrganizationsMemberTagsBulkDestroyResponse.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.OrganizationsClient.Delete2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.Delete2.g.cs index 5f76b02..1a5e028 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.Delete2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.Delete2.g.cs @@ -14,6 +14,7 @@ public partial class OrganizationsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -49,11 +50,13 @@ partial void ProcessDelete2Response( /// /// /// + /// 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 Delete2Async( int id, int tagPk, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -69,22 +72,43 @@ partial void ProcessDelete2Response( securityRequirements: s_Delete2SecurityRequirements, operationName: "Delete2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/organizations/{id}/member-tags/{tagPk}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/organizations/{id}/member-tags/{tagPk}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,162 +118,321 @@ partial void ProcessDelete2Response( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDelete2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - tagPk: tagPk); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDelete2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + tagPk: tagPk); - 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); - ProcessDelete2Response( - httpClient: HttpClient, - httpResponseMessage: __response); - // - if ((int)__response.StatusCode == 403) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_403 = null; - global::System.Exception? __exception_403 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/organizations/{id}/member-tags/{tagPk}\"", + 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_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + __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_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/organizations/{id}/member-tags/{tagPk}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/organizations/{id}/member-tags/{tagPk}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_403 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::LabelStudio.ApiException( - message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_403, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_403, - 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); + ProcessDelete2Response( + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/organizations/{id}/member-tags/{tagPk}\"", + 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 { - __exception_404 = __ex; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/organizations/{id}/member-tags/{tagPk}\"", + httpMethod: "DELETE", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } + // + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } - throw new global::LabelStudio.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), - }; - } + throw new global::LabelStudio.ApiException( + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + statusCode: __response.StatusCode) + { + ResponseBody = __content_403, + 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::LabelStudio.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), + }; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); - try - { - __response.EnsureSuccessStatusCode(); + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.OrganizationsClient.Delete3.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.Delete3.g.cs index c90bb99..d03f9d1 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.Delete3.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.Delete3.g.cs @@ -14,6 +14,7 @@ public partial class OrganizationsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -43,11 +44,13 @@ partial void ProcessDelete3Response( /// /// /// + /// 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 Delete3Async( int id, int userPk, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -63,22 +66,43 @@ partial void ProcessDelete3Response( securityRequirements: s_Delete3SecurityRequirements, operationName: "Delete3Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/organizations/{id}/memberships/{userPk}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/organizations/{id}/memberships/{userPk}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -88,195 +112,354 @@ partial void ProcessDelete3Response( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDelete3Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - userPk: userPk); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDelete3Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + userPk: userPk); - 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); - ProcessDelete3Response( - httpClient: HttpClient, - httpResponseMessage: __response); - // - if ((int)__response.StatusCode == 403) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_403 = null; - global::System.Exception? __exception_403 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete3", + methodName: "Delete3Async", + pathTemplate: "$\"/api/organizations/{id}/memberships/{userPk}/\"", + 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_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + __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_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - } - } - catch (global::System.Exception __ex) - { - __exception_403 = __ex; - } + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete3", + methodName: "Delete3Async", + pathTemplate: "$\"/api/organizations/{id}/memberships/{userPk}/\"", + 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; + } - throw new global::LabelStudio.ApiException( - message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_403, - statusCode: __response.StatusCode) - { - ResponseBody = __content_403, - 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 (ReadResponseAsString) - { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else + + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete3", + methodName: "Delete3Async", + pathTemplate: "$\"/api/organizations/{id}/memberships/{userPk}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_404 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::LabelStudio.ApiException( - message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_404, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_404, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // - if ((int)__response.StatusCode == 405) - { - string? __content_405 = null; - global::System.Exception? __exception_405 = null; - try + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessDelete3Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - if (ReadResponseAsString) - { - __content_405 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - } - else - { - __content_405 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete3", + methodName: "Delete3Async", + pathTemplate: "$\"/api/organizations/{id}/memberships/{userPk}/\"", + 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 { - __exception_405 = __ex; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete3", + methodName: "Delete3Async", + pathTemplate: "$\"/api/organizations/{id}/memberships/{userPk}/\"", + httpMethod: "DELETE", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } + // + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } - throw new global::LabelStudio.ApiException( - message: __content_405 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_405, - statusCode: __response.StatusCode) - { - ResponseBody = __content_405, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } + throw new global::LabelStudio.ApiException( + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + statusCode: __response.StatusCode) + { + ResponseBody = __content_403, + 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::LabelStudio.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), + }; + } + // + if ((int)__response.StatusCode == 405) + { + string? __content_405 = null; + global::System.Exception? __exception_405 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_405 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_405 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_405 = __ex; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + throw new global::LabelStudio.ApiException( + message: __content_405 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_405, + statusCode: __response.StatusCode) + { + ResponseBody = __content_405, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } - try - { - __response.EnsureSuccessStatusCode(); + 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.OrganizationsClient.Delete4.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.Delete4.g.cs index 76b9e0f..11d998d 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.Delete4.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.Delete4.g.cs @@ -14,6 +14,7 @@ public partial class OrganizationsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -49,11 +50,13 @@ partial void ProcessDelete4Response( /// /// /// + /// 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 Delete4Async( int id, string permission, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -69,22 +72,43 @@ partial void ProcessDelete4Response( securityRequirements: s_Delete4SecurityRequirements, operationName: "Delete4Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/organizations/{id}/permissions/{permission}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/organizations/{id}/permissions/{permission}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,162 +118,321 @@ partial void ProcessDelete4Response( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDelete4Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - permission: permission); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDelete4Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + permission: permission); - 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); - ProcessDelete4Response( - httpClient: HttpClient, - httpResponseMessage: __response); - // - if ((int)__response.StatusCode == 403) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_403 = null; - global::System.Exception? __exception_403 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete4", + methodName: "Delete4Async", + pathTemplate: "$\"/api/organizations/{id}/permissions/{permission}\"", + 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_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + __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_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete4", + methodName: "Delete4Async", + pathTemplate: "$\"/api/organizations/{id}/permissions/{permission}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete4", + methodName: "Delete4Async", + pathTemplate: "$\"/api/organizations/{id}/permissions/{permission}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_403 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::LabelStudio.ApiException( - message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_403, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_403, - 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); + ProcessDelete4Response( + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete4", + methodName: "Delete4Async", + pathTemplate: "$\"/api/organizations/{id}/permissions/{permission}\"", + 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 { - __exception_404 = __ex; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete4", + methodName: "Delete4Async", + pathTemplate: "$\"/api/organizations/{id}/permissions/{permission}\"", + httpMethod: "DELETE", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } + // + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } - throw new global::LabelStudio.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), - }; - } + throw new global::LabelStudio.ApiException( + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + statusCode: __response.StatusCode) + { + ResponseBody = __content_403, + 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::LabelStudio.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), + }; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); - try - { - __response.EnsureSuccessStatusCode(); + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.OrganizationsClient.Get2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.Get2.g.cs index b7c301e..9747677 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.Get2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.Get2.g.cs @@ -14,6 +14,7 @@ public partial class OrganizationsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -54,11 +55,13 @@ partial void ProcessGet2ResponseContent( /// /// /// + /// 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 Get2Async( int id, int tagPk, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -74,22 +77,43 @@ partial void ProcessGet2ResponseContent( securityRequirements: s_Get2SecurityRequirements, operationName: "Get2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/organizations/{id}/member-tags/{tagPk}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/organizations/{id}/member-tags/{tagPk}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -99,146 +123,305 @@ partial void ProcessGet2ResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGet2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - tagPk: tagPk); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGet2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + tagPk: tagPk); - 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); - ProcessGet2Response( - httpClient: HttpClient, - httpResponseMessage: __response); - // - if ((int)__response.StatusCode == 404) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_404 = null; - global::System.Exception? __exception_404 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "$\"/api/organizations/{id}/member-tags/{tagPk}\"", + 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) { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "$\"/api/organizations/{id}/member-tags/{tagPk}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else + + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "$\"/api/organizations/{id}/member-tags/{tagPk}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_404 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::LabelStudio.ApiException( - message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_404, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_404, - 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); - ProcessGet2ResponseContent( + response: __response); + ProcessGet2Response( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::LabelStudio.OrganizationMemberTag.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "$\"/api/organizations/{id}/member-tags/{tagPk}\"", + 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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "$\"/api/organizations/{id}/member-tags/{tagPk}\"", + 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); + // + 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; + } - return - await global::LabelStudio.OrganizationMemberTag.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) - { - } + throw new global::LabelStudio.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), + }; + } + + 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); + ProcessGet2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.OrganizationMemberTag.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.OrganizationMemberTag.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.OrganizationsClient.Get3.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.Get3.g.cs index 72c4b2b..b697ade 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.Get3.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.Get3.g.cs @@ -14,6 +14,7 @@ public partial class OrganizationsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,12 +52,14 @@ partial void ProcessGet3ResponseContent( /// /// /// + /// 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 Get3Async( int id, int userPk, bool? contributedToProjects = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -73,25 +76,46 @@ partial void ProcessGet3ResponseContent( securityRequirements: s_Get3SecurityRequirements, operationName: "Get3Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/organizations/{id}/memberships/{userPk}/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("contributed_to_projects", contributedToProjects?.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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/organizations/{id}/memberships/{userPk}/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("contributed_to_projects", contributedToProjects?.ToString().ToLowerInvariant()) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -101,114 +125,273 @@ partial void ProcessGet3ResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGet3Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - contributedToProjects: contributedToProjects, - id: id, - userPk: userPk); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGet3Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + contributedToProjects: contributedToProjects, + id: id, + userPk: userPk); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGet3Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get3", + methodName: "Get3Async", + pathTemplate: "$\"/api/organizations/{id}/memberships/{userPk}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get3", + methodName: "Get3Async", + pathTemplate: "$\"/api/organizations/{id}/memberships/{userPk}/\"", + 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); - ProcessGet3ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get3", + methodName: "Get3Async", + pathTemplate: "$\"/api/organizations/{id}/memberships/{userPk}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.OrganizationMember.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.OrganizationMember.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGet3Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get3", + methodName: "Get3Async", + pathTemplate: "$\"/api/organizations/{id}/memberships/{userPk}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get3", + methodName: "Get3Async", + pathTemplate: "$\"/api/organizations/{id}/memberships/{userPk}/\"", + 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); + ProcessGet3ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.OrganizationMember.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.OrganizationMember.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.OrganizationsClient.Get4.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.Get4.g.cs index 36934ec..65d2555 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.Get4.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.Get4.g.cs @@ -14,6 +14,7 @@ public partial class OrganizationsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -54,11 +55,13 @@ partial void ProcessGet4ResponseContent( /// /// /// + /// 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 Get4Async( int id, string permission, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -74,22 +77,43 @@ partial void ProcessGet4ResponseContent( securityRequirements: s_Get4SecurityRequirements, operationName: "Get4Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/organizations/{id}/permissions/{permission}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/organizations/{id}/permissions/{permission}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -99,179 +123,338 @@ partial void ProcessGet4ResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGet4Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - permission: permission); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGet4Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + permission: permission); - 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); - ProcessGet4Response( - httpClient: HttpClient, - httpResponseMessage: __response); - // - if ((int)__response.StatusCode == 403) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_403 = null; - global::System.Exception? __exception_403 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get4", + methodName: "Get4Async", + pathTemplate: "$\"/api/organizations/{id}/permissions/{permission}\"", + 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_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + __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_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - } - } - catch (global::System.Exception __ex) - { - __exception_403 = __ex; - } + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get4", + methodName: "Get4Async", + pathTemplate: "$\"/api/organizations/{id}/permissions/{permission}\"", + 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; + } - throw new global::LabelStudio.ApiException( - message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_403, - statusCode: __response.StatusCode) - { - ResponseBody = __content_403, - 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 (ReadResponseAsString) - { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else + + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get4", + methodName: "Get4Async", + pathTemplate: "$\"/api/organizations/{id}/permissions/{permission}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_404 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::LabelStudio.ApiException( - message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_404, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_404, - 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); - ProcessGet4ResponseContent( + response: __response); + ProcessGet4Response( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::LabelStudio.OrganizationPermission.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get4", + methodName: "Get4Async", + pathTemplate: "$\"/api/organizations/{id}/permissions/{permission}\"", + 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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get4", + methodName: "Get4Async", + pathTemplate: "$\"/api/organizations/{id}/permissions/{permission}\"", + 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); + // + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } - return - await global::LabelStudio.OrganizationPermission.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) - { - } + throw new global::LabelStudio.ApiException( + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + statusCode: __response.StatusCode) + { + ResponseBody = __content_403, + 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; + } + + throw new global::LabelStudio.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), + }; + } + + 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); + ProcessGet4ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.OrganizationPermission.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.OrganizationPermission.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.OrganizationsClient.GetImport.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.GetImport.g.cs index e0f0251..5d4a10f 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.GetImport.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.GetImport.g.cs @@ -14,6 +14,7 @@ public partial class OrganizationsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -55,11 +56,13 @@ partial void ProcessGetImportResponseContent( /// /// /// + /// 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 GetImportAsync( int id, int importPk, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -75,22 +78,43 @@ partial void ProcessGetImportResponseContent( securityRequirements: s_GetImportSecurityRequirements, operationName: "GetImportAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/organizations/{id}/member-tags/imports/{importPk}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/organizations/{id}/member-tags/imports/{importPk}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,179 +124,338 @@ partial void ProcessGetImportResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetImportRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - importPk: importPk); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetImportRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + importPk: importPk); - 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); - ProcessGetImportResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // - if ((int)__response.StatusCode == 403) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_403 = null; - global::System.Exception? __exception_403 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetImport", + methodName: "GetImportAsync", + pathTemplate: "$\"/api/organizations/{id}/member-tags/imports/{importPk}\"", + 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_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + __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_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - } - } - catch (global::System.Exception __ex) - { - __exception_403 = __ex; - } + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetImport", + methodName: "GetImportAsync", + pathTemplate: "$\"/api/organizations/{id}/member-tags/imports/{importPk}\"", + 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; + } - throw new global::LabelStudio.ApiException( - message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_403, - statusCode: __response.StatusCode) - { - ResponseBody = __content_403, - 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 (ReadResponseAsString) - { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else + + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetImport", + methodName: "GetImportAsync", + pathTemplate: "$\"/api/organizations/{id}/member-tags/imports/{importPk}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_404 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::LabelStudio.ApiException( - message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_404, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_404, - 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); - ProcessGetImportResponseContent( + response: __response); + ProcessGetImportResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::LabelStudio.OrganizationMemberTagImportStatus.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetImport", + methodName: "GetImportAsync", + pathTemplate: "$\"/api/organizations/{id}/member-tags/imports/{importPk}\"", + 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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetImport", + methodName: "GetImportAsync", + pathTemplate: "$\"/api/organizations/{id}/member-tags/imports/{importPk}\"", + 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); + // + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } - return - await global::LabelStudio.OrganizationMemberTagImportStatus.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) - { - } + throw new global::LabelStudio.ApiException( + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + statusCode: __response.StatusCode) + { + ResponseBody = __content_403, + 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; + } + + throw new global::LabelStudio.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), + }; + } + + 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); + ProcessGetImportResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.OrganizationMemberTagImportStatus.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.OrganizationMemberTagImportStatus.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.OrganizationsClient.GetInviteLink.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.GetInviteLink.g.cs index 8c34b54..8467d75 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.GetInviteLink.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.GetInviteLink.g.cs @@ -14,6 +14,7 @@ public partial class OrganizationsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -42,9 +43,11 @@ partial void ProcessGetInviteLinkResponseContent( /// Get invite link
/// Get invite link for 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 GetInviteLinkAsync( + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -58,22 +61,43 @@ partial void ProcessGetInviteLinkResponseContent( securityRequirements: s_GetInviteLinkSecurityRequirements, operationName: "GetInviteLinkAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/invite", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/invite", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,144 +107,303 @@ partial void ProcessGetInviteLinkResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetInviteLinkRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetInviteLinkRequest( + 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); - ProcessGetInviteLinkResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // - if ((int)__response.StatusCode == 403) + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_403 = null; - global::System.Exception? __exception_403 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetInviteLink", + methodName: "GetInviteLinkAsync", + pathTemplate: "\"/api/invite\"", + 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_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + __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_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetInviteLink", + methodName: "GetInviteLinkAsync", + pathTemplate: "\"/api/invite\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetInviteLink", + methodName: "GetInviteLinkAsync", + pathTemplate: "\"/api/invite\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_403 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::LabelStudio.ApiException( - message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_403, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_403, - 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); - ProcessGetInviteLinkResponseContent( + response: __response); + ProcessGetInviteLinkResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::LabelStudio.OrganizationInvite.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetInviteLink", + methodName: "GetInviteLinkAsync", + pathTemplate: "\"/api/invite\"", + 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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetInviteLink", + methodName: "GetInviteLinkAsync", + pathTemplate: "\"/api/invite\"", + 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); + // + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } - return - await global::LabelStudio.OrganizationInvite.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) - { - } + throw new global::LabelStudio.ApiException( + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + statusCode: __response.StatusCode) + { + ResponseBody = __content_403, + 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); + ProcessGetInviteLinkResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.OrganizationInvite.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.OrganizationInvite.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.OrganizationsClient.GetOptions.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.GetOptions.g.cs index cde211d..c217ecf 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.GetOptions.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.GetOptions.g.cs @@ -14,6 +14,7 @@ public partial class OrganizationsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -54,11 +55,13 @@ partial void ProcessGetOptionsResponseContent( /// /// /// + /// 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> GetOptionsAsync( int id, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -74,25 +77,46 @@ partial void ProcessGetOptionsResponseContent( securityRequirements: s_GetOptionsSecurityRequirements, operationName: "GetOptionsAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/organizations/{id}/permissions/options", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("ordering", ordering) - ; - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/organizations/{id}/permissions/options", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("ordering", ordering) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,113 +126,272 @@ partial void ProcessGetOptionsResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetOptionsRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - ordering: ordering); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetOptionsRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + ordering: ordering); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetOptionsResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetOptions", + methodName: "GetOptionsAsync", + pathTemplate: "$\"/api/organizations/{id}/permissions/options\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetOptions", + methodName: "GetOptionsAsync", + pathTemplate: "$\"/api/organizations/{id}/permissions/options\"", + 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); - ProcessGetOptionsResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetOptions", + methodName: "GetOptionsAsync", + pathTemplate: "$\"/api/organizations/{id}/permissions/options\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGetOptionsResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetOptions", + methodName: "GetOptionsAsync", + pathTemplate: "$\"/api/organizations/{id}/permissions/options\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetOptions", + methodName: "GetOptionsAsync", + pathTemplate: "$\"/api/organizations/{id}/permissions/options\"", + 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); + ProcessGetOptionsResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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 + (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.OrganizationsClient.Import.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.Import.g.cs index 48ab75a..d8e22ce 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.Import.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.Import.g.cs @@ -14,6 +14,7 @@ public partial class OrganizationsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -57,12 +58,14 @@ partial void ProcessImportResponseContent( /// /// /// + /// 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 ImportAsync( int id, global::LabelStudio.OrganizationMemberTagImportCreateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -80,22 +83,43 @@ partial void ProcessImportResponseContent( securityRequirements: s_ImportSecurityRequirements, operationName: "ImportAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/organizations/{id}/member-tags/imports", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/organizations/{id}/member-tags/imports", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,185 +129,344 @@ partial void ProcessImportResponseContent( __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/x-www-form-urlencoded"); - __httpRequest.Content = __httpRequestContent; - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareImportRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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/x-www-form-urlencoded"); + __httpRequest.Content = __httpRequestContent; + global::LabelStudio.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); + PrepareImportRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessImportResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // - if ((int)__response.StatusCode == 400) + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_400 = null; - global::System.Exception? __exception_400 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Import", + methodName: "ImportAsync", + pathTemplate: "$\"/api/organizations/{id}/member-tags/imports\"", + 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_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + __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_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - } - } - catch (global::System.Exception __ex) - { - __exception_400 = __ex; - } + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Import", + methodName: "ImportAsync", + pathTemplate: "$\"/api/organizations/{id}/member-tags/imports\"", + 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; + } - throw new global::LabelStudio.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 == 403) - { - string? __content_403 = null; - global::System.Exception? __exception_403 = null; - try - { - if (ReadResponseAsString) - { - __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else + + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Import", + methodName: "ImportAsync", + pathTemplate: "$\"/api/organizations/{id}/member-tags/imports\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_403 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::LabelStudio.ApiException( - message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_403, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_403, - 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); - ProcessImportResponseContent( + response: __response); + ProcessImportResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::LabelStudio.ApiOrganizationsMemberTagsImportsCreateResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Import", + methodName: "ImportAsync", + pathTemplate: "$\"/api/organizations/{id}/member-tags/imports\"", + 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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Import", + methodName: "ImportAsync", + pathTemplate: "$\"/api/organizations/{id}/member-tags/imports\"", + 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); + // + 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; + } - return - await global::LabelStudio.ApiOrganizationsMemberTagsImportsCreateResponse.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) - { - } + throw new global::LabelStudio.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 == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } + + throw new global::LabelStudio.ApiException( + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + statusCode: __response.StatusCode) + { + ResponseBody = __content_403, + 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); + ProcessImportResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.ApiOrganizationsMemberTagsImportsCreateResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiOrganizationsMemberTagsImportsCreateResponse.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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(); + } } /// /// ✨ Import member tags from CSV
@@ -302,6 +485,7 @@ partial void ProcessImportResponseContent( /// /// /// + /// 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 ImportAsync( @@ -309,6 +493,7 @@ partial void ProcessImportResponseContent( string bulkTags, byte[] file, string filename, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.OrganizationMemberTagImportCreateRequest @@ -321,6 +506,7 @@ partial void ProcessImportResponseContent( return await ImportAsync( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.List2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.List2.g.cs index 4bcfb61..4b70ccc 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.List2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.List2.g.cs @@ -14,6 +14,7 @@ public partial class OrganizationsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -63,6 +64,7 @@ partial void ProcessList2ResponseContent( /// /// /// + /// 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 List2Async( @@ -71,6 +73,7 @@ partial void ProcessList2ResponseContent( int? page = default, int? pageSize = default, string? search = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -89,28 +92,49 @@ partial void ProcessList2ResponseContent( securityRequirements: s_List2SecurityRequirements, operationName: "List2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/organizations/{id}/member-tags", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("ordering", ordering) - .AddOptionalParameter("page", page?.ToString()) - .AddOptionalParameter("page_size", pageSize?.ToString()) - .AddOptionalParameter("search", search) - ; - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/organizations/{id}/member-tags", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("ordering", ordering) + .AddOptionalParameter("page", page?.ToString()) + .AddOptionalParameter("page_size", pageSize?.ToString()) + .AddOptionalParameter("search", search) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -120,116 +144,275 @@ partial void ProcessList2ResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareList2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - ordering: ordering, - page: page, - pageSize: pageSize, - search: search); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareList2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + ordering: ordering, + page: page, + pageSize: pageSize, + search: search); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessList2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "$\"/api/organizations/{id}/member-tags\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "$\"/api/organizations/{id}/member-tags\"", + 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); - ProcessList2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "$\"/api/organizations/{id}/member-tags\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.PaginatedOrganizationMemberTagList.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.PaginatedOrganizationMemberTagList.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessList2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "$\"/api/organizations/{id}/member-tags\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "$\"/api/organizations/{id}/member-tags\"", + 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); + ProcessList2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.PaginatedOrganizationMemberTagList.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.PaginatedOrganizationMemberTagList.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.OrganizationsClient.List3.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.List3.g.cs index 3dbacba..515bc47 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.List3.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.List3.g.cs @@ -14,6 +14,7 @@ public partial class OrganizationsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -81,6 +82,7 @@ partial void ProcessList3ResponseContent( /// /// /// + /// 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 List3Async( @@ -95,6 +97,7 @@ partial void ProcessList3ResponseContent( global::LabelStudio.ApiOrganizationsMembershipsListScope? scope = default, string? search = default, string? tags = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -119,34 +122,55 @@ partial void ProcessList3ResponseContent( securityRequirements: s_List3SecurityRequirements, operationName: "List3Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/organizations/{id}/memberships", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("contributed_to_projects", contributedToProjects?.ToString().ToLowerInvariant()) - .AddOptionalParameter("exclude_project_id", excludeProjectId?.ToString()) - .AddOptionalParameter("exclude_workspace_id", excludeWorkspaceId?.ToString()) - .AddOptionalParameter("ordering", ordering) - .AddOptionalParameter("page", page?.ToString()) - .AddOptionalParameter("page_size", pageSize?.ToString()) - .AddOptionalParameter("role", role) - .AddOptionalParameter("scope", scope?.ToValueString()) - .AddOptionalParameter("search", search) - .AddOptionalParameter("tags", tags) - ; - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/organizations/{id}/memberships", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("contributed_to_projects", contributedToProjects?.ToString().ToLowerInvariant()) + .AddOptionalParameter("exclude_project_id", excludeProjectId?.ToString()) + .AddOptionalParameter("exclude_workspace_id", excludeWorkspaceId?.ToString()) + .AddOptionalParameter("ordering", ordering) + .AddOptionalParameter("page", page?.ToString()) + .AddOptionalParameter("page_size", pageSize?.ToString()) + .AddOptionalParameter("role", role) + .AddOptionalParameter("scope", scope?.ToValueString()) + .AddOptionalParameter("search", search) + .AddOptionalParameter("tags", tags) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -156,122 +180,281 @@ partial void ProcessList3ResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareList3Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - contributedToProjects: contributedToProjects, - excludeProjectId: excludeProjectId, - excludeWorkspaceId: excludeWorkspaceId, - id: id, - ordering: ordering, - page: page, - pageSize: pageSize, - role: role, - scope: scope, - search: search, - tags: tags); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareList3Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + contributedToProjects: contributedToProjects, + excludeProjectId: excludeProjectId, + excludeWorkspaceId: excludeWorkspaceId, + id: id, + ordering: ordering, + page: page, + pageSize: pageSize, + role: role, + scope: scope, + search: search, + tags: tags); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessList3Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List3", + methodName: "List3Async", + pathTemplate: "$\"/api/organizations/{id}/memberships\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List3", + methodName: "List3Async", + pathTemplate: "$\"/api/organizations/{id}/memberships\"", + 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); - ProcessList3ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List3", + methodName: "List3Async", + pathTemplate: "$\"/api/organizations/{id}/memberships\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.PaginatedLseOrganizationMemberListList.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.PaginatedLseOrganizationMemberListList.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessList3Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List3", + methodName: "List3Async", + pathTemplate: "$\"/api/organizations/{id}/memberships\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List3", + methodName: "List3Async", + pathTemplate: "$\"/api/organizations/{id}/memberships\"", + 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); + ProcessList3ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.PaginatedLseOrganizationMemberListList.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.PaginatedLseOrganizationMemberListList.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.OrganizationsClient.List4.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.List4.g.cs index dc95ccf..011e13e 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.List4.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.List4.g.cs @@ -14,6 +14,7 @@ public partial class OrganizationsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -54,11 +55,13 @@ partial void ProcessList4ResponseContent( ///
/// /// + /// 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> List4Async( int id, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -74,25 +77,46 @@ partial void ProcessList4ResponseContent( securityRequirements: s_List4SecurityRequirements, operationName: "List4Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/organizations/{id}/permissions", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("ordering", ordering) - ; - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/organizations/{id}/permissions", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("ordering", ordering) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,113 +126,272 @@ partial void ProcessList4ResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareList4Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - ordering: ordering); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareList4Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + ordering: ordering); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessList4Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List4", + methodName: "List4Async", + pathTemplate: "$\"/api/organizations/{id}/permissions\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List4", + methodName: "List4Async", + pathTemplate: "$\"/api/organizations/{id}/permissions\"", + 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); - ProcessList4ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List4", + methodName: "List4Async", + pathTemplate: "$\"/api/organizations/{id}/permissions\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessList4Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List4", + methodName: "List4Async", + pathTemplate: "$\"/api/organizations/{id}/permissions\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List4", + methodName: "List4Async", + pathTemplate: "$\"/api/organizations/{id}/permissions\"", + 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); + ProcessList4ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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 + (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.OrganizationsClient.Post.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.Post.g.cs index 3cd5855..3782458 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.Post.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.Post.g.cs @@ -14,6 +14,7 @@ public partial class OrganizationsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -54,12 +55,14 @@ partial void ProcessPostResponseContent( /// /// /// + /// 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 PostAsync( int id, global::LabelStudio.OrganizationMemberTagBulkCreateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -77,22 +80,43 @@ partial void ProcessPostResponseContent( securityRequirements: s_PostSecurityRequirements, operationName: "PostAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/organizations/{id}/member-tags/bulk", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/organizations/{id}/member-tags/bulk", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -102,185 +126,344 @@ partial void ProcessPostResponseContent( __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); - PreparePostRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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::LabelStudio.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); + PreparePostRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessPostResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // - if ((int)__response.StatusCode == 400) + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_400 = null; - global::System.Exception? __exception_400 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Post", + methodName: "PostAsync", + pathTemplate: "$\"/api/organizations/{id}/member-tags/bulk\"", + 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_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + __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_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - } - } - catch (global::System.Exception __ex) - { - __exception_400 = __ex; - } + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Post", + methodName: "PostAsync", + pathTemplate: "$\"/api/organizations/{id}/member-tags/bulk\"", + 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; + } - throw new global::LabelStudio.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 == 403) - { - string? __content_403 = null; - global::System.Exception? __exception_403 = null; - try - { - if (ReadResponseAsString) - { - __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else + + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Post", + methodName: "PostAsync", + pathTemplate: "$\"/api/organizations/{id}/member-tags/bulk\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_403 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::LabelStudio.ApiException( - message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_403, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_403, - 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); - ProcessPostResponseContent( + response: __response); + ProcessPostResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::LabelStudio.ApiOrganizationsMemberTagsBulkCreateResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Post", + methodName: "PostAsync", + pathTemplate: "$\"/api/organizations/{id}/member-tags/bulk\"", + 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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Post", + methodName: "PostAsync", + pathTemplate: "$\"/api/organizations/{id}/member-tags/bulk\"", + 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); + // + 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; + } - return - await global::LabelStudio.ApiOrganizationsMemberTagsBulkCreateResponse.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) - { - } + throw new global::LabelStudio.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 == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } + + throw new global::LabelStudio.ApiException( + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + statusCode: __response.StatusCode) + { + ResponseBody = __content_403, + 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); + ProcessPostResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.ApiOrganizationsMemberTagsBulkCreateResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiOrganizationsMemberTagsBulkCreateResponse.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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(); + } } /// /// ✨ Bulk create organization member tags
@@ -296,11 +479,13 @@ partial void ProcessPostResponseContent( /// /// List of tag labels to create. /// + /// 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 PostAsync( int id, global::System.Collections.Generic.IList labels, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.OrganizationMemberTagBulkCreateRequest @@ -311,6 +496,7 @@ partial void ProcessPostResponseContent( return await PostAsync( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.Replace.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.Replace.g.cs index 7812c35..075a619 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.Replace.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.Replace.g.cs @@ -14,6 +14,7 @@ public partial class OrganizationsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -57,6 +58,7 @@ partial void ProcessReplaceResponseContent( /// /// /// + /// 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 ReplaceAsync( @@ -64,6 +66,7 @@ partial void ProcessReplaceResponseContent( string permission, global::LabelStudio.OrganizationPermissionRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -82,22 +85,43 @@ partial void ProcessReplaceResponseContent( securityRequirements: s_ReplaceSecurityRequirements, operationName: "ReplaceAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/organizations/{id}/permissions/{permission}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/organizations/{id}/permissions/{permission}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -107,219 +131,378 @@ partial void ProcessReplaceResponseContent( __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); - PrepareReplaceRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - permission: permission, - 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::LabelStudio.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); + PrepareReplaceRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + permission: permission, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessReplaceResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // - if ((int)__response.StatusCode == 400) + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_400 = null; - global::System.Exception? __exception_400 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Replace", + methodName: "ReplaceAsync", + pathTemplate: "$\"/api/organizations/{id}/permissions/{permission}\"", + 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_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + __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_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - } - } - catch (global::System.Exception __ex) - { - __exception_400 = __ex; - } + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Replace", + methodName: "ReplaceAsync", + pathTemplate: "$\"/api/organizations/{id}/permissions/{permission}\"", + 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; + } - throw new global::LabelStudio.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 == 403) - { - string? __content_403 = null; - global::System.Exception? __exception_403 = null; - try - { - if (ReadResponseAsString) - { - __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else + + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Replace", + methodName: "ReplaceAsync", + pathTemplate: "$\"/api/organizations/{id}/permissions/{permission}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_403 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::LabelStudio.ApiException( - message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_403, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_403, - 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); + ProcessReplaceResponse( + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Replace", + methodName: "ReplaceAsync", + pathTemplate: "$\"/api/organizations/{id}/permissions/{permission}\"", + 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 { - __exception_404 = __ex; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Replace", + methodName: "ReplaceAsync", + pathTemplate: "$\"/api/organizations/{id}/permissions/{permission}\"", + httpMethod: "PUT", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } + // + 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::LabelStudio.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), - }; - } + throw new global::LabelStudio.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 == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + throw new global::LabelStudio.ApiException( + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + statusCode: __response.StatusCode) + { + ResponseBody = __content_403, + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessReplaceResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + throw new global::LabelStudio.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), + }; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); - return - global::LabelStudio.OrganizationPermission.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); - } - catch (global::System.Exception __ex) - { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - cancellationToken -#endif - ).ConfigureAwait(false); + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessReplaceResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); - return - await global::LabelStudio.OrganizationPermission.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) - { - } + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.OrganizationPermission.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.OrganizationPermission.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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(); + } } /// /// ✨ Replace organization permission override
@@ -337,6 +520,7 @@ partial void ProcessReplaceResponseContent( /// /// Organization roles /// + /// 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 ReplaceAsync( @@ -344,6 +528,7 @@ partial void ProcessReplaceResponseContent( string permission, string requestPermission, global::System.Collections.Generic.IList? roles = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.OrganizationPermissionRequest @@ -356,6 +541,7 @@ partial void ProcessReplaceResponseContent( id: id, permission: permission, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.RevokeInvite.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.RevokeInvite.g.cs index 48706db..5589fed 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.RevokeInvite.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.RevokeInvite.g.cs @@ -14,6 +14,7 @@ public partial class OrganizationsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -46,11 +47,13 @@ partial void ProcessRevokeInviteResponse( /// Revoke invite to 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 RevokeInviteAsync( global::LabelStudio.RevokeInviteRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -67,22 +70,43 @@ partial void ProcessRevokeInviteResponse( securityRequirements: s_RevokeInviteSecurityRequirements, operationName: "RevokeInviteAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/invite/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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/invite/revoke", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -92,102 +116,261 @@ partial void ProcessRevokeInviteResponse( __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); - PrepareRevokeInviteRequest( - 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::LabelStudio.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); + PrepareRevokeInviteRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessRevokeInviteResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RevokeInvite", + methodName: "RevokeInviteAsync", + pathTemplate: "\"/api/invite/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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RevokeInvite", + methodName: "RevokeInviteAsync", + pathTemplate: "\"/api/invite/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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RevokeInvite", + methodName: "RevokeInviteAsync", + pathTemplate: "\"/api/invite/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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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) + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessRevokeInviteResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RevokeInvite", + methodName: "RevokeInviteAsync", + pathTemplate: "\"/api/invite/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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RevokeInvite", + methodName: "RevokeInviteAsync", + pathTemplate: "\"/api/invite/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); + } + + 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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(); + } } /// /// ✨ Revoke invite
@@ -202,10 +385,12 @@ partial void ProcessRevokeInviteResponse( /// /// Email address /// + /// 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 RevokeInviteAsync( string email, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.RevokeInviteRequest @@ -215,6 +400,7 @@ partial void ProcessRevokeInviteResponse( await RevokeInviteAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.SendEmail.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.SendEmail.g.cs index f08d375..24cf640 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.SendEmail.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.SendEmail.g.cs @@ -14,6 +14,7 @@ public partial class OrganizationsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -46,11 +47,13 @@ partial void ProcessSendEmailResponse( /// Send email with invite to 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 SendEmailAsync( global::LabelStudio.SendInviteRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -67,22 +70,43 @@ partial void ProcessSendEmailResponse( securityRequirements: s_SendEmailSecurityRequirements, operationName: "SendEmailAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/invite/send-email", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/invite/send-email", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -92,135 +116,294 @@ partial void ProcessSendEmailResponse( __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::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareSendEmailRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - request: request); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareSendEmailRequest( + 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); - ProcessSendEmailResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // - if ((int)__response.StatusCode == 403) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_403 = null; - global::System.Exception? __exception_403 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "SendEmail", + methodName: "SendEmailAsync", + pathTemplate: "\"/api/invite/send-email\"", + 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_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "SendEmail", + methodName: "SendEmailAsync", + pathTemplate: "\"/api/invite/send-email\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else + + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "SendEmail", + methodName: "SendEmailAsync", + pathTemplate: "\"/api/invite/send-email\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_403 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::LabelStudio.ApiException( - message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_403, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_403, - 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); - - try - { - __response.EnsureSuccessStatusCode(); - - } - catch (global::System.Exception __ex) + response: __response); + ProcessSendEmailResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "SendEmail", + methodName: "SendEmailAsync", + pathTemplate: "\"/api/invite/send-email\"", + 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 + else { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "SendEmail", + methodName: "SendEmailAsync", + pathTemplate: "\"/api/invite/send-email\"", + 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) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + // + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } + + throw new global::LabelStudio.ApiException( + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + statusCode: __response.StatusCode) + { + ResponseBody = __content_403, + 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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(); + } } /// /// ✨ Send email with invite
@@ -251,6 +434,7 @@ partial void ProcessSendEmailResponse( /// /// Workspace IDs to grant access to /// + /// 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 SendEmailAsync( @@ -258,6 +442,7 @@ partial void ProcessSendEmailResponse( global::LabelStudio.Role9e7Enum role, global::System.Collections.Generic.IList? projects = default, global::System.Collections.Generic.IList? workspaces = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.SendInviteRequest @@ -270,6 +455,7 @@ partial void ProcessSendEmailResponse( await SendEmailAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.Update.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.Update.g.cs index 8c55941..2ffcfc4 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.Update.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.Update.g.cs @@ -14,6 +14,7 @@ public partial class OrganizationsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -54,12 +55,14 @@ partial void ProcessUpdateResponseContent( ///
/// /// + /// 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 UpdateAsync( int id, global::LabelStudio.PatchedLseOrganizationSerializerUpdateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -77,22 +80,43 @@ partial void ProcessUpdateResponseContent( securityRequirements: s_UpdateSecurityRequirements, operationName: "UpdateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/organizations/{id}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/organizations/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -102,218 +126,377 @@ partial void ProcessUpdateResponseContent( __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); - PrepareUpdateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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::LabelStudio.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); + PrepareUpdateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessUpdateResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // - if ((int)__response.StatusCode == 400) + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_400 = null; - global::System.Exception? __exception_400 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/organizations/{id}\"", + 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_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + __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_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - } - } - catch (global::System.Exception __ex) - { - __exception_400 = __ex; - } + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/organizations/{id}\"", + 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; + } - throw new global::LabelStudio.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 == 403) - { - string? __content_403 = null; - global::System.Exception? __exception_403 = null; - try - { - if (ReadResponseAsString) - { - __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else + + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/organizations/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_403 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::LabelStudio.ApiException( - message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_403, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_403, - 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); + ProcessUpdateResponse( + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/organizations/{id}\"", + 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 { - __exception_404 = __ex; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/organizations/{id}\"", + httpMethod: "PATCH", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } + // + 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::LabelStudio.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), - }; - } + throw new global::LabelStudio.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 == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + throw new global::LabelStudio.ApiException( + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + statusCode: __response.StatusCode) + { + ResponseBody = __content_403, + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessUpdateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + throw new global::LabelStudio.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), + }; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); - return - global::LabelStudio.LseOrganization.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); - } - catch (global::System.Exception __ex) - { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - cancellationToken -#endif - ).ConfigureAwait(false); + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessUpdateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); - return - await global::LabelStudio.LseOrganization.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) - { - } + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.LseOrganization.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.LseOrganization.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 organization
@@ -353,6 +536,7 @@ partial void ProcessUpdateResponseContent( /// Included only in requests /// /// + /// 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 UpdateAsync( @@ -366,6 +550,7 @@ partial void ProcessUpdateResponseContent( string? contactInfo = default, int? createdBy = default, string? token = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.PatchedLseOrganizationSerializerUpdateRequest @@ -384,6 +569,7 @@ partial void ProcessUpdateResponseContent( return await UpdateAsync( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.Update2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.Update2.g.cs index 66ccf45..de0a6ab 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.Update2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.Update2.g.cs @@ -14,6 +14,7 @@ public partial class OrganizationsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -57,6 +58,7 @@ partial void ProcessUpdate2ResponseContent( /// /// /// + /// 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 Update2Async( @@ -64,6 +66,7 @@ partial void ProcessUpdate2ResponseContent( int tagPk, global::LabelStudio.PatchedOrganizationMemberTagRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -82,22 +85,43 @@ partial void ProcessUpdate2ResponseContent( securityRequirements: s_Update2SecurityRequirements, operationName: "Update2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/organizations/{id}/member-tags/{tagPk}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/organizations/{id}/member-tags/{tagPk}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -107,219 +131,378 @@ partial void ProcessUpdate2ResponseContent( __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); - PrepareUpdate2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - tagPk: tagPk, - 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::LabelStudio.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); + PrepareUpdate2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + tagPk: tagPk, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessUpdate2Response( - httpClient: HttpClient, - httpResponseMessage: __response); - // - if ((int)__response.StatusCode == 400) + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_400 = null; - global::System.Exception? __exception_400 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/organizations/{id}/member-tags/{tagPk}\"", + 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_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + __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_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - } - } - catch (global::System.Exception __ex) - { - __exception_400 = __ex; - } + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/organizations/{id}/member-tags/{tagPk}\"", + 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; + } - throw new global::LabelStudio.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 == 403) - { - string? __content_403 = null; - global::System.Exception? __exception_403 = null; - try - { - if (ReadResponseAsString) - { - __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else + + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/organizations/{id}/member-tags/{tagPk}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_403 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::LabelStudio.ApiException( - message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_403, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_403, - 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); + ProcessUpdate2Response( + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/organizations/{id}/member-tags/{tagPk}\"", + 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 { - __exception_404 = __ex; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/organizations/{id}/member-tags/{tagPk}\"", + httpMethod: "PATCH", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } + // + 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::LabelStudio.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), - }; - } + throw new global::LabelStudio.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 == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + throw new global::LabelStudio.ApiException( + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + statusCode: __response.StatusCode) + { + ResponseBody = __content_403, + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessUpdate2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + throw new global::LabelStudio.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), + }; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); - return - global::LabelStudio.OrganizationMemberTag.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); - } - catch (global::System.Exception __ex) - { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - cancellationToken -#endif - ).ConfigureAwait(false); + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessUpdate2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); - return - await global::LabelStudio.OrganizationMemberTag.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) - { - } + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.OrganizationMemberTag.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.OrganizationMemberTag.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 organization member tag
@@ -336,12 +519,14 @@ partial void ProcessUpdate2ResponseContent( /// /// Label /// + /// 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 Update2Async( int id, int tagPk, string? label = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.PatchedOrganizationMemberTagRequest @@ -353,6 +538,7 @@ partial void ProcessUpdate2ResponseContent( id: id, tagPk: tagPk, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.Update3.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.Update3.g.cs index 3c57158..0eea38e 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.Update3.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.Update3.g.cs @@ -14,6 +14,7 @@ public partial class OrganizationsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -60,12 +61,14 @@ partial void ProcessUpdate3ResponseContent( ///
/// /// + /// 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 Update3Async( int id, global::LabelStudio.PatchedOrganizationMemberCreateUpdateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -83,22 +86,43 @@ partial void ProcessUpdate3ResponseContent( securityRequirements: s_Update3SecurityRequirements, operationName: "Update3Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/organizations/{id}/memberships", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/organizations/{id}/memberships", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -108,119 +132,278 @@ partial void ProcessUpdate3ResponseContent( __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); - PrepareUpdate3Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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::LabelStudio.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); + PrepareUpdate3Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessUpdate3Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update3", + methodName: "Update3Async", + pathTemplate: "$\"/api/organizations/{id}/memberships\"", + 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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update3", + methodName: "Update3Async", + pathTemplate: "$\"/api/organizations/{id}/memberships\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessUpdate3ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update3", + methodName: "Update3Async", + pathTemplate: "$\"/api/organizations/{id}/memberships\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.LseOrganizationMemberList.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.LseOrganizationMemberList.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessUpdate3Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update3", + methodName: "Update3Async", + pathTemplate: "$\"/api/organizations/{id}/memberships\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update3", + methodName: "Update3Async", + pathTemplate: "$\"/api/organizations/{id}/memberships\"", + httpMethod: "PATCH", + 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); + ProcessUpdate3ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.LseOrganizationMemberList.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.LseOrganizationMemberList.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 organization member/role
@@ -252,12 +435,14 @@ partial void ProcessUpdate3ResponseContent( /// /// Member /// + /// 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 Update3Async( int id, global::LabelStudio.Role9e7Enum? role = default, int? userId = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.PatchedOrganizationMemberCreateUpdateRequest @@ -269,6 +454,7 @@ partial void ProcessUpdate3ResponseContent( return await Update3Async( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.Update4.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.Update4.g.cs index 2b68484..b341bad 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.Update4.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.Update4.g.cs @@ -14,6 +14,7 @@ public partial class OrganizationsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -57,6 +58,7 @@ partial void ProcessUpdate4ResponseContent( /// /// /// + /// 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 Update4Async( @@ -64,6 +66,7 @@ partial void ProcessUpdate4ResponseContent( string permission, global::LabelStudio.PatchedOrganizationPermissionRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -82,22 +85,43 @@ partial void ProcessUpdate4ResponseContent( securityRequirements: s_Update4SecurityRequirements, operationName: "Update4Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/organizations/{id}/permissions/{permission}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/organizations/{id}/permissions/{permission}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -107,219 +131,378 @@ partial void ProcessUpdate4ResponseContent( __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); - PrepareUpdate4Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - permission: permission, - 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::LabelStudio.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); + PrepareUpdate4Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + permission: permission, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessUpdate4Response( - httpClient: HttpClient, - httpResponseMessage: __response); - // - if ((int)__response.StatusCode == 400) + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_400 = null; - global::System.Exception? __exception_400 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update4", + methodName: "Update4Async", + pathTemplate: "$\"/api/organizations/{id}/permissions/{permission}\"", + 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_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + __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_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - } - } - catch (global::System.Exception __ex) - { - __exception_400 = __ex; - } + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update4", + methodName: "Update4Async", + pathTemplate: "$\"/api/organizations/{id}/permissions/{permission}\"", + 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; + } - throw new global::LabelStudio.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 == 403) - { - string? __content_403 = null; - global::System.Exception? __exception_403 = null; - try - { - if (ReadResponseAsString) - { - __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else + + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update4", + methodName: "Update4Async", + pathTemplate: "$\"/api/organizations/{id}/permissions/{permission}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_403 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::LabelStudio.ApiException( - message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_403, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_403, - 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); + ProcessUpdate4Response( + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update4", + methodName: "Update4Async", + pathTemplate: "$\"/api/organizations/{id}/permissions/{permission}\"", + 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 { - __exception_404 = __ex; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update4", + methodName: "Update4Async", + pathTemplate: "$\"/api/organizations/{id}/permissions/{permission}\"", + httpMethod: "PATCH", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } + // + 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::LabelStudio.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), - }; - } + throw new global::LabelStudio.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 == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + throw new global::LabelStudio.ApiException( + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + statusCode: __response.StatusCode) + { + ResponseBody = __content_403, + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessUpdate4ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + throw new global::LabelStudio.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), + }; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); - return - global::LabelStudio.OrganizationPermission.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); - } - catch (global::System.Exception __ex) - { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - cancellationToken -#endif - ).ConfigureAwait(false); + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessUpdate4ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); - return - await global::LabelStudio.OrganizationPermission.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) - { - } + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.OrganizationPermission.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.OrganizationPermission.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 organization permission override
@@ -337,6 +520,7 @@ partial void ProcessUpdate4ResponseContent( /// /// Organization roles /// + /// 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 Update4Async( @@ -344,6 +528,7 @@ partial void ProcessUpdate4ResponseContent( string permission, string? requestPermission = default, global::System.Collections.Generic.IList? roles = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.PatchedOrganizationPermissionRequest @@ -356,6 +541,7 @@ partial void ProcessUpdate4ResponseContent( id: id, permission: permission, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.UpdateDefaultRole.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.UpdateDefaultRole.g.cs index 90143b4..be7583b 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.UpdateDefaultRole.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.UpdateDefaultRole.g.cs @@ -14,6 +14,7 @@ public partial class OrganizationsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -54,12 +55,14 @@ partial void ProcessUpdateDefaultRoleResponseContent( ///
/// /// + /// 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 UpdateDefaultRoleAsync( int id, global::LabelStudio.PatchedDefaultRoleRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -77,22 +80,43 @@ partial void ProcessUpdateDefaultRoleResponseContent( securityRequirements: s_UpdateDefaultRoleSecurityRequirements, operationName: "UpdateDefaultRoleAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/organizations/{id}/set-default-role", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/organizations/{id}/set-default-role", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -102,119 +126,278 @@ partial void ProcessUpdateDefaultRoleResponseContent( __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); - PrepareUpdateDefaultRoleRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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::LabelStudio.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); + PrepareUpdateDefaultRoleRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessUpdateDefaultRoleResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateDefaultRole", + methodName: "UpdateDefaultRoleAsync", + pathTemplate: "$\"/api/organizations/{id}/set-default-role\"", + 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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateDefaultRole", + methodName: "UpdateDefaultRoleAsync", + pathTemplate: "$\"/api/organizations/{id}/set-default-role\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessUpdateDefaultRoleResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateDefaultRole", + methodName: "UpdateDefaultRoleAsync", + pathTemplate: "$\"/api/organizations/{id}/set-default-role\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.DefaultRole.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.DefaultRole.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessUpdateDefaultRoleResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateDefaultRole", + methodName: "UpdateDefaultRoleAsync", + pathTemplate: "$\"/api/organizations/{id}/set-default-role\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateDefaultRole", + methodName: "UpdateDefaultRoleAsync", + pathTemplate: "$\"/api/organizations/{id}/set-default-role\"", + httpMethod: "PATCH", + 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); + ProcessUpdateDefaultRoleResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.DefaultRole.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.DefaultRole.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 default role
@@ -268,6 +451,7 @@ partial void ProcessUpdateDefaultRoleResponseContent( /// /// Set to current time to prevent creating or editing annotations in quick view. /// + /// 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 UpdateDefaultRoleAsync( @@ -284,6 +468,7 @@ partial void ProcessUpdateDefaultRoleResponseContent( int? organization = default, object? reactCodeSettings = default, global::System.DateTime? readOnlyQuickViewEnabledAt = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.PatchedDefaultRoleRequest @@ -305,6 +490,7 @@ partial void ProcessUpdateDefaultRoleResponseContent( return await UpdateDefaultRoleAsync( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.g.cs index 12c50b4..df88b52 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.OrganizationsClient.g.cs @@ -30,6 +30,9 @@ public sealed partial class OrganizationsClient : global::LabelStudio.IOrganizat #if DEBUG = true; #endif + + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public OrganizationsClient( 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 OrganizationsClient. + /// 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 OrganizationsClient( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::LabelStudio.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::LabelStudio.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/LabelStudio/Generated/LabelStudio.PathBuilder.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.PathBuilder.g.cs index 28f8d79..128cd21 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.PathBuilder.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.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/LabelStudio/Generated/LabelStudio.PausesClient.ApiProjectsMembersPausesUpdate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.PausesClient.ApiProjectsMembersPausesUpdate.g.cs index 414ff0f..e49dc68 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.PausesClient.ApiProjectsMembersPausesUpdate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.PausesClient.ApiProjectsMembersPausesUpdate.g.cs @@ -14,6 +14,7 @@ public partial class PausesClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -60,6 +61,7 @@ partial void ProcessApiProjectsMembersPausesUpdateResponseContent( /// /// /// + /// 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 ApiProjectsMembersPausesUpdateAsync( @@ -68,6 +70,7 @@ partial void ProcessApiProjectsMembersPausesUpdateResponseContent( int userPk, global::LabelStudio.PauseRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -87,22 +90,43 @@ partial void ProcessApiProjectsMembersPausesUpdateResponseContent( securityRequirements: s_ApiProjectsMembersPausesUpdateSecurityRequirements, operationName: "ApiProjectsMembersPausesUpdateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{projectPk}/members/{userPk}/pauses/{id}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{projectPk}/members/{userPk}/pauses/{id}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -112,121 +136,280 @@ partial void ProcessApiProjectsMembersPausesUpdateResponseContent( __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); - PrepareApiProjectsMembersPausesUpdateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - projectPk: projectPk, - userPk: userPk, - 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::LabelStudio.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); + PrepareApiProjectsMembersPausesUpdateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + projectPk: projectPk, + userPk: userPk, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiProjectsMembersPausesUpdateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiProjectsMembersPausesUpdate", + methodName: "ApiProjectsMembersPausesUpdateAsync", + pathTemplate: "$\"/api/projects/{projectPk}/members/{userPk}/pauses/{id}/\"", + 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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiProjectsMembersPausesUpdate", + methodName: "ApiProjectsMembersPausesUpdateAsync", + pathTemplate: "$\"/api/projects/{projectPk}/members/{userPk}/pauses/{id}/\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessApiProjectsMembersPausesUpdateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiProjectsMembersPausesUpdate", + methodName: "ApiProjectsMembersPausesUpdateAsync", + pathTemplate: "$\"/api/projects/{projectPk}/members/{userPk}/pauses/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.Pause.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.Pause.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessApiProjectsMembersPausesUpdateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiProjectsMembersPausesUpdate", + methodName: "ApiProjectsMembersPausesUpdateAsync", + pathTemplate: "$\"/api/projects/{projectPk}/members/{userPk}/pauses/{id}/\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiProjectsMembersPausesUpdate", + methodName: "ApiProjectsMembersPausesUpdateAsync", + pathTemplate: "$\"/api/projects/{projectPk}/members/{userPk}/pauses/{id}/\"", + httpMethod: "PUT", + 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); + ProcessApiProjectsMembersPausesUpdateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.Pause.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.Pause.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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(); + } } /// /// ✨ Put pause
@@ -252,6 +435,7 @@ partial void ProcessApiProjectsMembersPausesUpdateResponseContent( /// /// Detailed description of why the project is paused, will be readable by paused annotators /// + /// 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 ApiProjectsMembersPausesUpdateAsync( @@ -260,6 +444,7 @@ partial void ProcessApiProjectsMembersPausesUpdateResponseContent( int userPk, global::LabelStudio.ReasonEnum reason, string? verboseReason = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.PauseRequest @@ -273,6 +458,7 @@ partial void ProcessApiProjectsMembersPausesUpdateResponseContent( projectPk: projectPk, userPk: userPk, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.PausesClient.Create.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.PausesClient.Create.g.cs index 3ed73c4..f332fdb 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.PausesClient.Create.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.PausesClient.Create.g.cs @@ -14,6 +14,7 @@ public partial class PausesClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -57,6 +58,7 @@ partial void ProcessCreateResponseContent( /// /// /// + /// 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 CreateAsync( @@ -64,6 +66,7 @@ partial void ProcessCreateResponseContent( int userPk, global::LabelStudio.PauseRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -82,22 +85,43 @@ partial void ProcessCreateResponseContent( securityRequirements: s_CreateSecurityRequirements, operationName: "CreateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{projectPk}/members/{userPk}/pauses/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{projectPk}/members/{userPk}/pauses/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -107,120 +131,279 @@ partial void ProcessCreateResponseContent( __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); - PrepareCreateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - projectPk: projectPk, - userPk: userPk, - 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::LabelStudio.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); + PrepareCreateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + projectPk: projectPk, + userPk: userPk, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "$\"/api/projects/{projectPk}/members/{userPk}/pauses/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "$\"/api/projects/{projectPk}/members/{userPk}/pauses/\"", + 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); - ProcessCreateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "$\"/api/projects/{projectPk}/members/{userPk}/pauses/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.Pause.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.Pause.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessCreateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "$\"/api/projects/{projectPk}/members/{userPk}/pauses/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "$\"/api/projects/{projectPk}/members/{userPk}/pauses/\"", + 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); + ProcessCreateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.Pause.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.Pause.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 pause
@@ -245,6 +428,7 @@ partial void ProcessCreateResponseContent( /// /// Detailed description of why the project is paused, will be readable by paused annotators /// + /// 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 CreateAsync( @@ -252,6 +436,7 @@ partial void ProcessCreateResponseContent( int userPk, global::LabelStudio.ReasonEnum reason, string? verboseReason = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.PauseRequest @@ -264,6 +449,7 @@ partial void ProcessCreateResponseContent( projectPk: projectPk, userPk: userPk, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.PausesClient.Delete.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.PausesClient.Delete.g.cs index e387027..0cbf10c 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.PausesClient.Delete.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.PausesClient.Delete.g.cs @@ -14,6 +14,7 @@ public partial class PausesClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -52,12 +53,14 @@ partial void ProcessDeleteResponse( /// /// /// + /// 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 DeleteAsync( string id, int projectPk, int userPk, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -74,22 +77,43 @@ partial void ProcessDeleteResponse( securityRequirements: s_DeleteSecurityRequirements, operationName: "DeleteAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{projectPk}/members/{userPk}/pauses/{id}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{projectPk}/members/{userPk}/pauses/{id}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -99,98 +123,257 @@ partial void ProcessDeleteResponse( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDeleteRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - projectPk: projectPk, - userPk: userPk); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDeleteRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + projectPk: projectPk, + userPk: userPk); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/projects/{projectPk}/members/{userPk}/pauses/{id}/\"", + 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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/projects/{projectPk}/members/{userPk}/pauses/{id}/\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessDeleteResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/projects/{projectPk}/members/{userPk}/pauses/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessDeleteResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/projects/{projectPk}/members/{userPk}/pauses/{id}/\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/projects/{projectPk}/members/{userPk}/pauses/{id}/\"", + httpMethod: "DELETE", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.PausesClient.Get.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.PausesClient.Get.g.cs index 0eedbf8..77c3f2e 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.PausesClient.Get.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.PausesClient.Get.g.cs @@ -14,6 +14,7 @@ public partial class PausesClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -57,12 +58,14 @@ partial void ProcessGetResponseContent( /// /// /// + /// 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 GetAsync( string id, int projectPk, int userPk, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -79,22 +82,43 @@ partial void ProcessGetResponseContent( securityRequirements: s_GetSecurityRequirements, operationName: "GetAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{projectPk}/members/{userPk}/pauses/{id}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{projectPk}/members/{userPk}/pauses/{id}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -104,114 +128,273 @@ partial void ProcessGetResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - projectPk: projectPk, - userPk: userPk); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + projectPk: projectPk, + userPk: userPk); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/projects/{projectPk}/members/{userPk}/pauses/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/projects/{projectPk}/members/{userPk}/pauses/{id}/\"", + 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); - ProcessGetResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/projects/{projectPk}/members/{userPk}/pauses/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.Pause.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.Pause.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGetResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/projects/{projectPk}/members/{userPk}/pauses/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/projects/{projectPk}/members/{userPk}/pauses/{id}/\"", + 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); + ProcessGetResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.Pause.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.Pause.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.PausesClient.List.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.PausesClient.List.g.cs index a5d9c4b..65485ea 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.PausesClient.List.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.PausesClient.List.g.cs @@ -14,6 +14,7 @@ public partial class PausesClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -60,6 +61,7 @@ partial void ProcessListResponseContent( /// /// /// + /// 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> ListAsync( @@ -67,6 +69,7 @@ partial void ProcessListResponseContent( int userPk, bool? includeDeleted = default, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -84,26 +87,47 @@ partial void ProcessListResponseContent( securityRequirements: s_ListSecurityRequirements, operationName: "ListAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{projectPk}/members/{userPk}/pauses/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("include_deleted", includeDeleted?.ToString().ToLowerInvariant()) - .AddOptionalParameter("ordering", ordering) - ; - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{projectPk}/members/{userPk}/pauses/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("include_deleted", includeDeleted?.ToString().ToLowerInvariant()) + .AddOptionalParameter("ordering", ordering) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -113,115 +137,274 @@ partial void ProcessListResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareListRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - includeDeleted: includeDeleted, - ordering: ordering, - projectPk: projectPk, - userPk: userPk); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareListRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + includeDeleted: includeDeleted, + ordering: ordering, + projectPk: projectPk, + userPk: userPk); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessListResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "$\"/api/projects/{projectPk}/members/{userPk}/pauses/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "$\"/api/projects/{projectPk}/members/{userPk}/pauses/\"", + 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); - ProcessListResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "$\"/api/projects/{projectPk}/members/{userPk}/pauses/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessListResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "$\"/api/projects/{projectPk}/members/{userPk}/pauses/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "$\"/api/projects/{projectPk}/members/{userPk}/pauses/\"", + 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); + ProcessListResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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 + (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.PausesClient.Update.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.PausesClient.Update.g.cs index 0a24e1e..87bfb54 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.PausesClient.Update.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.PausesClient.Update.g.cs @@ -14,6 +14,7 @@ public partial class PausesClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -60,6 +61,7 @@ partial void ProcessUpdateResponseContent( /// /// /// + /// 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 UpdateAsync( @@ -68,6 +70,7 @@ partial void ProcessUpdateResponseContent( int userPk, global::LabelStudio.PatchedPauseRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -87,22 +90,43 @@ partial void ProcessUpdateResponseContent( securityRequirements: s_UpdateSecurityRequirements, operationName: "UpdateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{projectPk}/members/{userPk}/pauses/{id}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{projectPk}/members/{userPk}/pauses/{id}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -112,121 +136,280 @@ partial void ProcessUpdateResponseContent( __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); - PrepareUpdateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - projectPk: projectPk, - userPk: userPk, - 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::LabelStudio.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); + PrepareUpdateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + projectPk: projectPk, + userPk: userPk, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessUpdateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/projects/{projectPk}/members/{userPk}/pauses/{id}/\"", + 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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/projects/{projectPk}/members/{userPk}/pauses/{id}/\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessUpdateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/projects/{projectPk}/members/{userPk}/pauses/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.Pause.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.Pause.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessUpdateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/projects/{projectPk}/members/{userPk}/pauses/{id}/\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/projects/{projectPk}/members/{userPk}/pauses/{id}/\"", + httpMethod: "PATCH", + 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); + ProcessUpdateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.Pause.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.Pause.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 pause
@@ -252,6 +435,7 @@ partial void ProcessUpdateResponseContent( /// /// Detailed description of why the project is paused, will be readable by paused annotators /// + /// 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 UpdateAsync( @@ -260,6 +444,7 @@ partial void ProcessUpdateResponseContent( int userPk, global::LabelStudio.ReasonEnum? reason = default, string? verboseReason = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.PatchedPauseRequest @@ -273,6 +458,7 @@ partial void ProcessUpdateResponseContent( projectPk: projectPk, userPk: userPk, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.PausesClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.PausesClient.g.cs index 5ad522f..5238bcd 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.PausesClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.PausesClient.g.cs @@ -30,6 +30,9 @@ public sealed partial class PausesClient : global::LabelStudio.IPausesClient, gl #if DEBUG = true; #endif + + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public PausesClient( 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 PausesClient. + /// 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 PausesClient( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::LabelStudio.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::LabelStudio.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/LabelStudio/Generated/LabelStudio.Predictions2Client.Create.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Predictions2Client.Create.g.cs index 379f3d0..887705c 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Predictions2Client.Create.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Predictions2Client.Create.g.cs @@ -14,6 +14,7 @@ public partial class Predictions2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,11 +46,13 @@ partial void ProcessCreateResponseContent( /// Create a prediction for a specific task. ///
/// + /// 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 CreateAsync( global::LabelStudio.ApiPredictionsCreateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -66,22 +69,43 @@ partial void ProcessCreateResponseContent( securityRequirements: s_CreateSecurityRequirements, operationName: "CreateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/predictions/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/predictions/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,118 +115,277 @@ partial void ProcessCreateResponseContent( __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); - PrepareCreateRequest( - 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::LabelStudio.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); + PrepareCreateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/predictions/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/predictions/\"", + 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); - ProcessCreateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/predictions/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.Prediction.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.Prediction.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessCreateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/predictions/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/predictions/\"", + 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); + ProcessCreateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.Prediction.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.Prediction.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 prediction
@@ -223,6 +406,7 @@ partial void ProcessCreateResponseContent( /// /// Task ID for which the prediction is created /// + /// 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 CreateAsync( @@ -230,6 +414,7 @@ partial void ProcessCreateResponseContent( global::System.Collections.Generic.IList? result = default, double? score = default, int? task = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.ApiPredictionsCreateRequest @@ -242,6 +427,7 @@ partial void ProcessCreateResponseContent( return await CreateAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.Predictions2Client.Delete.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Predictions2Client.Delete.g.cs index 6fea61a..c773d76 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Predictions2Client.Delete.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Predictions2Client.Delete.g.cs @@ -14,6 +14,7 @@ public partial class Predictions2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -40,10 +41,12 @@ partial void ProcessDeleteResponse( /// Delete a prediction by prediction ID. /// /// + /// 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 DeleteAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -58,22 +61,43 @@ partial void ProcessDeleteResponse( securityRequirements: s_DeleteSecurityRequirements, operationName: "DeleteAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/predictions/{id}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/predictions/{id}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -83,96 +107,255 @@ partial void ProcessDeleteResponse( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDeleteRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDeleteRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/predictions/{id}/\"", + 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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/predictions/{id}/\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessDeleteResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/predictions/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessDeleteResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/predictions/{id}/\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/predictions/{id}/\"", + httpMethod: "DELETE", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.Predictions2Client.Get.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Predictions2Client.Get.g.cs index ac322f9..28d18d0 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Predictions2Client.Get.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Predictions2Client.Get.g.cs @@ -14,6 +14,7 @@ public partial class Predictions2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,10 +46,12 @@ partial void ProcessGetResponseContent( /// Get details about a specific prediction by its ID. /// /// + /// 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 GetAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -63,22 +66,43 @@ partial void ProcessGetResponseContent( securityRequirements: s_GetSecurityRequirements, operationName: "GetAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/predictions/{id}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/predictions/{id}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -88,112 +112,271 @@ partial void ProcessGetResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/predictions/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/predictions/{id}/\"", + 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); - ProcessGetResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/predictions/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.Prediction.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.Prediction.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGetResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/predictions/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/predictions/{id}/\"", + 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); + ProcessGetResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.Prediction.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.Prediction.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.Predictions2Client.List.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Predictions2Client.List.g.cs index 94d9a7a..ed196e5 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Predictions2Client.List.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Predictions2Client.List.g.cs @@ -14,6 +14,7 @@ public partial class Predictions2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -48,11 +49,13 @@ partial void ProcessListResponseContent( /// /// /// + /// 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> ListAsync( int? project = default, int? task = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -68,26 +71,47 @@ partial void ProcessListResponseContent( securityRequirements: s_ListSecurityRequirements, operationName: "ListAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/predictions/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("project", project?.ToString()) - .AddOptionalParameter("task", task?.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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/predictions/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("project", project?.ToString()) + .AddOptionalParameter("task", task?.ToString()) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -97,113 +121,272 @@ partial void ProcessListResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareListRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - project: project, - task: task); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareListRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + project: project, + task: task); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessListResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/predictions/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/predictions/\"", + 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); - ProcessListResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/predictions/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessListResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/predictions/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/predictions/\"", + 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); + ProcessListResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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 + (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.Predictions2Client.Update.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Predictions2Client.Update.g.cs index 482d33d..867e212 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Predictions2Client.Update.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Predictions2Client.Update.g.cs @@ -14,6 +14,7 @@ public partial class Predictions2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -48,12 +49,14 @@ partial void ProcessUpdateResponseContent( /// /// /// + /// 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 UpdateAsync( int id, global::LabelStudio.ApiPredictionsPartialUpdateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -71,22 +74,43 @@ partial void ProcessUpdateResponseContent( securityRequirements: s_UpdateSecurityRequirements, operationName: "UpdateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/predictions/{id}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/predictions/{id}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -96,119 +120,278 @@ partial void ProcessUpdateResponseContent( __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); - PrepareUpdateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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::LabelStudio.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); + PrepareUpdateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessUpdateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/predictions/{id}/\"", + 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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/predictions/{id}/\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessUpdateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/predictions/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.Prediction.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.Prediction.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessUpdateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/predictions/{id}/\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/predictions/{id}/\"", + httpMethod: "PATCH", + 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); + ProcessUpdateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.Prediction.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.Prediction.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 prediction
@@ -230,6 +413,7 @@ partial void ProcessUpdateResponseContent( /// /// Task ID for which the prediction is created /// + /// 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 UpdateAsync( @@ -238,6 +422,7 @@ partial void ProcessUpdateResponseContent( global::System.Collections.Generic.IList? result = default, double? score = default, int? task = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.ApiPredictionsPartialUpdateRequest @@ -251,6 +436,7 @@ partial void ProcessUpdateResponseContent( return await UpdateAsync( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.Predictions2Client.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Predictions2Client.g.cs index 0288663..25fe1e7 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Predictions2Client.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Predictions2Client.g.cs @@ -30,6 +30,9 @@ public sealed partial class Predictions2Client : global::LabelStudio.IPrediction #if DEBUG = true; #endif + + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public Predictions2Client( 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 Predictions2Client. + /// 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 Predictions2Client( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::LabelStudio.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::LabelStudio.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/LabelStudio/Generated/LabelStudio.PredictionsClient.ApiPredictionsUpdate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.PredictionsClient.ApiPredictionsUpdate.g.cs index 372af27..9f68b0a 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.PredictionsClient.ApiPredictionsUpdate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.PredictionsClient.ApiPredictionsUpdate.g.cs @@ -14,6 +14,7 @@ public partial class PredictionsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -48,12 +49,14 @@ partial void ProcessApiPredictionsUpdateResponseContent( /// /// /// + /// 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 ApiPredictionsUpdateAsync( int id, global::LabelStudio.ApiPredictionsUpdateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -71,22 +74,43 @@ partial void ProcessApiPredictionsUpdateResponseContent( securityRequirements: s_ApiPredictionsUpdateSecurityRequirements, operationName: "ApiPredictionsUpdateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/predictions/{id}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/predictions/{id}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -96,119 +120,278 @@ partial void ProcessApiPredictionsUpdateResponseContent( __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); - PrepareApiPredictionsUpdateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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::LabelStudio.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); + PrepareApiPredictionsUpdateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiPredictionsUpdateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiPredictionsUpdate", + methodName: "ApiPredictionsUpdateAsync", + pathTemplate: "$\"/api/predictions/{id}/\"", + 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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiPredictionsUpdate", + methodName: "ApiPredictionsUpdateAsync", + pathTemplate: "$\"/api/predictions/{id}/\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessApiPredictionsUpdateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiPredictionsUpdate", + methodName: "ApiPredictionsUpdateAsync", + pathTemplate: "$\"/api/predictions/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.Prediction.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.Prediction.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessApiPredictionsUpdateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiPredictionsUpdate", + methodName: "ApiPredictionsUpdateAsync", + pathTemplate: "$\"/api/predictions/{id}/\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiPredictionsUpdate", + methodName: "ApiPredictionsUpdateAsync", + pathTemplate: "$\"/api/predictions/{id}/\"", + httpMethod: "PUT", + 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); + ProcessApiPredictionsUpdateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.Prediction.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.Prediction.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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(); + } } /// /// Put prediction
@@ -230,6 +413,7 @@ partial void ProcessApiPredictionsUpdateResponseContent( /// /// Task ID for which the prediction is created /// + /// 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 ApiPredictionsUpdateAsync( @@ -238,6 +422,7 @@ partial void ProcessApiPredictionsUpdateResponseContent( global::System.Collections.Generic.IList? result = default, double? score = default, int? task = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.ApiPredictionsUpdateRequest @@ -251,6 +436,7 @@ partial void ProcessApiPredictionsUpdateResponseContent( return await ApiPredictionsUpdateAsync( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.PredictionsClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.PredictionsClient.g.cs index c972ce4..1b45314 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.PredictionsClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.PredictionsClient.g.cs @@ -30,6 +30,9 @@ public sealed partial class PredictionsClient : global::LabelStudio.IPredictions #if DEBUG = true; #endif + + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public PredictionsClient( 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 PredictionsClient. + /// 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 PredictionsClient( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::LabelStudio.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::LabelStudio.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ProjectRolesClient.Add.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ProjectRolesClient.Add.g.cs index 1edf57b..0807f43 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ProjectRolesClient.Add.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ProjectRolesClient.Add.g.cs @@ -14,6 +14,7 @@ public partial class ProjectRolesClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -52,11 +53,13 @@ partial void ProcessAddResponseContent( /// /// /// + /// 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 AddAsync( global::LabelStudio.ProjectRoleRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -73,22 +76,43 @@ partial void ProcessAddResponseContent( securityRequirements: s_AddSecurityRequirements, operationName: "AddAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/projects/roles/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/projects/roles/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -98,118 +122,277 @@ partial void ProcessAddResponseContent( __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::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareAddRequest( - 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); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareAddRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessAddResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Add", + methodName: "AddAsync", + pathTemplate: "\"/api/projects/roles/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Add", + methodName: "AddAsync", + pathTemplate: "\"/api/projects/roles/\"", + 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); - ProcessAddResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Add", + methodName: "AddAsync", + pathTemplate: "\"/api/projects/roles/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.ProjectRole.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.ProjectRole.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessAddResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Add", + methodName: "AddAsync", + pathTemplate: "\"/api/projects/roles/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Add", + methodName: "AddAsync", + pathTemplate: "\"/api/projects/roles/\"", + 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); + ProcessAddResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.ProjectRole.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ProjectRole.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 project role for user
@@ -233,12 +416,14 @@ partial void ProcessAddResponseContent( /// * `NO` - Not Activated /// /// + /// 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 AddAsync( int project, global::LabelStudio.Role9e7Enum role, int user, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.ProjectRoleRequest @@ -250,6 +435,7 @@ partial void ProcessAddResponseContent( return await AddAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ProjectRolesClient.Get.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ProjectRolesClient.Get.g.cs index b0ed999..3f82751 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ProjectRolesClient.Get.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ProjectRolesClient.Get.g.cs @@ -14,6 +14,7 @@ public partial class ProjectRolesClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -53,10 +54,12 @@ partial void ProcessGetResponseContent( /// ///
/// + /// 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> GetAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -71,22 +74,43 @@ partial void ProcessGetResponseContent( securityRequirements: s_GetSecurityRequirements, operationName: "GetAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{id}/roles", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{id}/roles", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -96,112 +120,271 @@ partial void ProcessGetResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/projects/{id}/roles\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/projects/{id}/roles\"", + 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); - ProcessGetResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/projects/{id}/roles\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGetResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/projects/{id}/roles\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/projects/{id}/roles\"", + 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); + ProcessGetResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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 + (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.ProjectRolesClient.List.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ProjectRolesClient.List.g.cs index 61da36f..fc77c27 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ProjectRolesClient.List.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ProjectRolesClient.List.g.cs @@ -14,6 +14,7 @@ public partial class ProjectRolesClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -55,11 +56,13 @@ partial void ProcessListResponseContent( /// /// /// + /// 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> ListAsync( int? ids = default, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -75,26 +78,47 @@ partial void ProcessListResponseContent( securityRequirements: s_ListSecurityRequirements, operationName: "ListAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/projects/roles/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("ids", ids?.ToString()) - .AddOptionalParameter("ordering", ordering) - ; - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/projects/roles/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("ids", ids?.ToString()) + .AddOptionalParameter("ordering", ordering) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -104,113 +128,272 @@ partial void ProcessListResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareListRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - ids: ids, - ordering: ordering); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareListRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + ids: ids, + ordering: ordering); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessListResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/projects/roles/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/projects/roles/\"", + 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); - ProcessListResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/projects/roles/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessListResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/projects/roles/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/projects/roles/\"", + 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); + ProcessListResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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 + (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.ProjectRolesClient.Remove.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ProjectRolesClient.Remove.g.cs index 4965f57..19249b2 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ProjectRolesClient.Remove.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ProjectRolesClient.Remove.g.cs @@ -14,6 +14,7 @@ public partial class ProjectRolesClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -47,10 +48,12 @@ partial void ProcessRemoveResponse( /// /// /// + /// 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 RemoveAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -65,22 +68,43 @@ partial void ProcessRemoveResponse( securityRequirements: s_RemoveSecurityRequirements, operationName: "RemoveAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/roles/{id}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/roles/{id}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -90,96 +114,255 @@ partial void ProcessRemoveResponse( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareRemoveRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareRemoveRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Remove", + methodName: "RemoveAsync", + pathTemplate: "$\"/api/projects/roles/{id}/\"", + 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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Remove", + methodName: "RemoveAsync", + pathTemplate: "$\"/api/projects/roles/{id}/\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessRemoveResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Remove", + methodName: "RemoveAsync", + pathTemplate: "$\"/api/projects/roles/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessRemoveResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Remove", + methodName: "RemoveAsync", + pathTemplate: "$\"/api/projects/roles/{id}/\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Remove", + methodName: "RemoveAsync", + pathTemplate: "$\"/api/projects/roles/{id}/\"", + httpMethod: "DELETE", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.ProjectRolesClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ProjectRolesClient.g.cs index b918e18..6d145fb 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ProjectRolesClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ProjectRolesClient.g.cs @@ -30,6 +30,9 @@ public sealed partial class ProjectRolesClient : global::LabelStudio.IProjectRol #if DEBUG = true; #endif + + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public ProjectRolesClient( 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 ProjectRolesClient. + /// 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 ProjectRolesClient( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::LabelStudio.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::LabelStudio.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ProjectTemplatesClient.ApiProjectTemplatesUpdate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ProjectTemplatesClient.ApiProjectTemplatesUpdate.g.cs index a22b528..3e83260 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ProjectTemplatesClient.ApiProjectTemplatesUpdate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ProjectTemplatesClient.ApiProjectTemplatesUpdate.g.cs @@ -14,6 +14,7 @@ public partial class ProjectTemplatesClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -54,12 +55,14 @@ partial void ProcessApiProjectTemplatesUpdateResponseContent( /// /// /// + /// 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 ApiProjectTemplatesUpdateAsync( int id, global::LabelStudio.ProjectTemplateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -77,22 +80,43 @@ partial void ProcessApiProjectTemplatesUpdateResponseContent( securityRequirements: s_ApiProjectTemplatesUpdateSecurityRequirements, operationName: "ApiProjectTemplatesUpdateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/project-templates/{id}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/project-templates/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -102,119 +126,278 @@ partial void ProcessApiProjectTemplatesUpdateResponseContent( __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); - PrepareApiProjectTemplatesUpdateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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::LabelStudio.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); + PrepareApiProjectTemplatesUpdateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiProjectTemplatesUpdateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiProjectTemplatesUpdate", + methodName: "ApiProjectTemplatesUpdateAsync", + pathTemplate: "$\"/api/project-templates/{id}\"", + 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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiProjectTemplatesUpdate", + methodName: "ApiProjectTemplatesUpdateAsync", + pathTemplate: "$\"/api/project-templates/{id}\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessApiProjectTemplatesUpdateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiProjectTemplatesUpdate", + methodName: "ApiProjectTemplatesUpdateAsync", + pathTemplate: "$\"/api/project-templates/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.ProjectTemplate.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.ProjectTemplate.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessApiProjectTemplatesUpdateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiProjectTemplatesUpdate", + methodName: "ApiProjectTemplatesUpdateAsync", + pathTemplate: "$\"/api/project-templates/{id}\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiProjectTemplatesUpdate", + methodName: "ApiProjectTemplatesUpdateAsync", + pathTemplate: "$\"/api/project-templates/{id}\"", + httpMethod: "PUT", + 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); + ProcessApiProjectTemplatesUpdateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.ProjectTemplate.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ProjectTemplate.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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(); + } } /// /// ✨ Overwrite a project template
@@ -251,6 +434,7 @@ partial void ProcessApiProjectTemplatesUpdateResponseContent( /// /// /// + /// 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 ApiProjectTemplatesUpdateAsync( @@ -267,6 +451,7 @@ partial void ProcessApiProjectTemplatesUpdateResponseContent( object? reviewSettings = default, bool? showUnusedDataColumnsToAnnotators = default, object? tags = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.ProjectTemplateRequest @@ -288,6 +473,7 @@ partial void ProcessApiProjectTemplatesUpdateResponseContent( return await ApiProjectTemplatesUpdateAsync( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ProjectTemplatesClient.Create.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ProjectTemplatesClient.Create.g.cs index b0a974f..513ebc3 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ProjectTemplatesClient.Create.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ProjectTemplatesClient.Create.g.cs @@ -14,6 +14,7 @@ public partial class ProjectTemplatesClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,11 +52,13 @@ partial void ProcessCreateResponseContent( /// Create a project template for an 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 CreateAsync( global::LabelStudio.ProjectTemplateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -72,22 +75,43 @@ partial void ProcessCreateResponseContent( securityRequirements: s_CreateSecurityRequirements, operationName: "CreateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/project-templates/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/project-templates/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -97,118 +121,277 @@ partial void ProcessCreateResponseContent( __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::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCreateRequest( - 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); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/project-templates/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/project-templates/\"", + 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); - ProcessCreateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/project-templates/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.ProjectTemplate.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.ProjectTemplate.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessCreateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/project-templates/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/project-templates/\"", + 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); + ProcessCreateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.ProjectTemplate.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ProjectTemplate.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 project template
@@ -244,6 +427,7 @@ partial void ProcessCreateResponseContent( /// /// /// + /// 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 CreateAsync( @@ -259,6 +443,7 @@ partial void ProcessCreateResponseContent( object? reviewSettings = default, bool? showUnusedDataColumnsToAnnotators = default, object? tags = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.ProjectTemplateRequest @@ -279,6 +464,7 @@ partial void ProcessCreateResponseContent( return await CreateAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ProjectTemplatesClient.CreateProjectFromTemplate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ProjectTemplatesClient.CreateProjectFromTemplate.g.cs index 854bf77..de6116e 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ProjectTemplatesClient.CreateProjectFromTemplate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ProjectTemplatesClient.CreateProjectFromTemplate.g.cs @@ -14,6 +14,7 @@ public partial class ProjectTemplatesClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -54,12 +55,14 @@ partial void ProcessCreateProjectFromTemplateResponseContent( ///
/// /// + /// 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 CreateProjectFromTemplateAsync( int id, global::LabelStudio.ApiProjectTemplatesCreateProjectCreateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -77,22 +80,43 @@ partial void ProcessCreateProjectFromTemplateResponseContent( securityRequirements: s_CreateProjectFromTemplateSecurityRequirements, operationName: "CreateProjectFromTemplateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/project-templates/{id}/create-project", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/project-templates/{id}/create-project", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -102,119 +126,278 @@ partial void ProcessCreateProjectFromTemplateResponseContent( __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); - PrepareCreateProjectFromTemplateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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::LabelStudio.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); + PrepareCreateProjectFromTemplateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreateProjectFromTemplateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateProjectFromTemplate", + methodName: "CreateProjectFromTemplateAsync", + pathTemplate: "$\"/api/project-templates/{id}/create-project\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateProjectFromTemplate", + methodName: "CreateProjectFromTemplateAsync", + pathTemplate: "$\"/api/project-templates/{id}/create-project\"", + 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); - ProcessCreateProjectFromTemplateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateProjectFromTemplate", + methodName: "CreateProjectFromTemplateAsync", + pathTemplate: "$\"/api/project-templates/{id}/create-project\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.LseProject.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.LseProject.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessCreateProjectFromTemplateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateProjectFromTemplate", + methodName: "CreateProjectFromTemplateAsync", + pathTemplate: "$\"/api/project-templates/{id}/create-project\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateProjectFromTemplate", + methodName: "CreateProjectFromTemplateAsync", + pathTemplate: "$\"/api/project-templates/{id}/create-project\"", + 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); + ProcessCreateProjectFromTemplateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.LseProject.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.LseProject.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 project from template
@@ -236,6 +419,7 @@ partial void ProcessCreateProjectFromTemplateResponseContent( /// /// A unique integer value identifying the workspace in which to create the project. /// + /// 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 CreateProjectFromTemplateAsync( @@ -243,6 +427,7 @@ partial void ProcessCreateProjectFromTemplateResponseContent( string title, int workspaceId, string? description = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.ApiProjectTemplatesCreateProjectCreateRequest @@ -255,6 +440,7 @@ partial void ProcessCreateProjectFromTemplateResponseContent( return await CreateProjectFromTemplateAsync( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ProjectTemplatesClient.Delete.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ProjectTemplatesClient.Delete.g.cs index 13dc446..a6f968b 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ProjectTemplatesClient.Delete.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ProjectTemplatesClient.Delete.g.cs @@ -14,6 +14,7 @@ public partial class ProjectTemplatesClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -46,10 +47,12 @@ partial void ProcessDeleteResponse( /// Delete a specific project template by ID for an 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 DeleteAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -64,22 +67,43 @@ partial void ProcessDeleteResponse( securityRequirements: s_DeleteSecurityRequirements, operationName: "DeleteAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/project-templates/{id}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/project-templates/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -89,96 +113,255 @@ partial void ProcessDeleteResponse( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDeleteRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDeleteRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/project-templates/{id}\"", + 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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/project-templates/{id}\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessDeleteResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/project-templates/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessDeleteResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/project-templates/{id}\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/project-templates/{id}\"", + httpMethod: "DELETE", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.ProjectTemplatesClient.Get.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ProjectTemplatesClient.Get.g.cs index ac7e7d0..0b8030d 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ProjectTemplatesClient.Get.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ProjectTemplatesClient.Get.g.cs @@ -14,6 +14,7 @@ public partial class ProjectTemplatesClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,10 +52,12 @@ partial void ProcessGetResponseContent( /// Get a specific project template by ID for an 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 GetAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -69,22 +72,43 @@ partial void ProcessGetResponseContent( securityRequirements: s_GetSecurityRequirements, operationName: "GetAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/project-templates/{id}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/project-templates/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,112 +118,271 @@ partial void ProcessGetResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/project-templates/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/project-templates/{id}\"", + 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); - ProcessGetResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/project-templates/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.ProjectTemplate.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.ProjectTemplate.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGetResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/project-templates/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/project-templates/{id}\"", + 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); + ProcessGetResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.ProjectTemplate.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ProjectTemplate.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.ProjectTemplatesClient.List.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ProjectTemplatesClient.List.g.cs index 6e142d1..a651ca4 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ProjectTemplatesClient.List.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ProjectTemplatesClient.List.g.cs @@ -14,6 +14,7 @@ public partial class ProjectTemplatesClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,10 +52,12 @@ partial void ProcessListResponseContent( /// Get a list of all project templates for an 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> ListAsync( string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -69,25 +72,46 @@ partial void ProcessListResponseContent( securityRequirements: s_ListSecurityRequirements, operationName: "ListAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/project-templates/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("ordering", ordering) - ; - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/project-templates/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("ordering", ordering) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -97,112 +121,271 @@ partial void ProcessListResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareListRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - ordering: ordering); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareListRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + ordering: ordering); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessListResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/project-templates/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/project-templates/\"", + 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); - ProcessListResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/project-templates/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessListResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/project-templates/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/project-templates/\"", + 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); + ProcessListResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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 + (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.ProjectTemplatesClient.Update.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ProjectTemplatesClient.Update.g.cs index cb28192..e1d31cb 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ProjectTemplatesClient.Update.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ProjectTemplatesClient.Update.g.cs @@ -14,6 +14,7 @@ public partial class ProjectTemplatesClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -54,12 +55,14 @@ partial void ProcessUpdateResponseContent( /// /// /// + /// 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 UpdateAsync( int id, global::LabelStudio.PatchedProjectTemplateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -77,22 +80,43 @@ partial void ProcessUpdateResponseContent( securityRequirements: s_UpdateSecurityRequirements, operationName: "UpdateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/project-templates/{id}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/project-templates/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -102,119 +126,278 @@ partial void ProcessUpdateResponseContent( __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); - PrepareUpdateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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::LabelStudio.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); + PrepareUpdateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessUpdateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/project-templates/{id}\"", + 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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/project-templates/{id}\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessUpdateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/project-templates/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.ProjectTemplate.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.ProjectTemplate.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessUpdateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/project-templates/{id}\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/project-templates/{id}\"", + httpMethod: "PATCH", + 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); + ProcessUpdateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.ProjectTemplate.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ProjectTemplate.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 project template
@@ -251,6 +434,7 @@ partial void ProcessUpdateResponseContent( /// /// /// + /// 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 UpdateAsync( @@ -267,6 +451,7 @@ partial void ProcessUpdateResponseContent( object? reviewSettings = default, bool? showUnusedDataColumnsToAnnotators = default, object? tags = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.PatchedProjectTemplateRequest @@ -288,6 +473,7 @@ partial void ProcessUpdateResponseContent( return await UpdateAsync( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ProjectTemplatesClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ProjectTemplatesClient.g.cs index febf083..1138b8e 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ProjectTemplatesClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ProjectTemplatesClient.g.cs @@ -30,6 +30,9 @@ public sealed partial class ProjectTemplatesClient : global::LabelStudio.IProjec #if DEBUG = true; #endif + + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public ProjectTemplatesClient( 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 ProjectTemplatesClient. + /// 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 ProjectTemplatesClient( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::LabelStudio.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::LabelStudio.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/LabelStudio/Generated/LabelStudio.Projects2Client.Create.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Projects2Client.Create.g.cs index ce285b8..2998eae 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Projects2Client.Create.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Projects2Client.Create.g.cs @@ -16,6 +16,7 @@ public partial class Projects2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -47,11 +48,13 @@ partial void ProcessCreateResponseContent( /// Create a project for a specific 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 CreateAsync( global::LabelStudio.LseProjectCreateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -68,22 +71,43 @@ partial void ProcessCreateResponseContent( securityRequirements: s_CreateSecurityRequirements, operationName: "CreateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/projects/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/projects/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,118 +117,277 @@ partial void ProcessCreateResponseContent( __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::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCreateRequest( - 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); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/projects/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/projects/\"", + 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); - ProcessCreateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/projects/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.LseProjectCreate.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.LseProjectCreate.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessCreateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/projects/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/projects/\"", + 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); + ProcessCreateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.LseProjectCreate.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.LseProjectCreate.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 project
@@ -285,6 +468,7 @@ partial void ProcessCreateResponseContent( /// /// In Workspace /// + /// 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 CreateAsync( @@ -317,6 +501,7 @@ partial void ProcessCreateResponseContent( string? taskDataPassword = default, string? title = default, int? workspace = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.LseProjectCreateRequest @@ -354,6 +539,7 @@ partial void ProcessCreateResponseContent( return await CreateAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.Projects2Client.Delete.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Projects2Client.Delete.g.cs index f7705fe..6680153 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Projects2Client.Delete.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Projects2Client.Delete.g.cs @@ -14,6 +14,7 @@ public partial class Projects2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -40,10 +41,12 @@ partial void ProcessDeleteResponse( /// Delete a project by specified project ID. ///
/// + /// 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 DeleteAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -58,22 +61,43 @@ partial void ProcessDeleteResponse( securityRequirements: s_DeleteSecurityRequirements, operationName: "DeleteAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{id}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{id}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -83,96 +107,255 @@ partial void ProcessDeleteResponse( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDeleteRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDeleteRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/projects/{id}/\"", + 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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/projects/{id}/\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessDeleteResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/projects/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessDeleteResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/projects/{id}/\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/projects/{id}/\"", + httpMethod: "DELETE", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.Projects2Client.Duplicate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Projects2Client.Duplicate.g.cs index 45b502f..6e892a0 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Projects2Client.Duplicate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Projects2Client.Duplicate.g.cs @@ -14,6 +14,7 @@ public partial class Projects2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -54,12 +55,14 @@ partial void ProcessDuplicateResponseContent( /// /// /// + /// 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 DuplicateAsync( int id, global::LabelStudio.ProjectDuplicateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -77,22 +80,43 @@ partial void ProcessDuplicateResponseContent( securityRequirements: s_DuplicateSecurityRequirements, operationName: "DuplicateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{id}/duplicate/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{id}/duplicate/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -102,119 +126,278 @@ partial void ProcessDuplicateResponseContent( __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); - PrepareDuplicateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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::LabelStudio.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); + PrepareDuplicateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessDuplicateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Duplicate", + methodName: "DuplicateAsync", + pathTemplate: "$\"/api/projects/{id}/duplicate/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Duplicate", + methodName: "DuplicateAsync", + pathTemplate: "$\"/api/projects/{id}/duplicate/\"", + 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); - ProcessDuplicateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Duplicate", + methodName: "DuplicateAsync", + pathTemplate: "$\"/api/projects/{id}/duplicate/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.ApiProjectsDuplicateCreateResponse.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.ApiProjectsDuplicateCreateResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessDuplicateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Duplicate", + methodName: "DuplicateAsync", + pathTemplate: "$\"/api/projects/{id}/duplicate/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Duplicate", + methodName: "DuplicateAsync", + pathTemplate: "$\"/api/projects/{id}/duplicate/\"", + 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); + ProcessDuplicateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.ApiProjectsDuplicateCreateResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiProjectsDuplicateCreateResponse.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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(); + } } /// /// ✨ Duplicate project
@@ -241,6 +424,7 @@ partial void ProcessDuplicateResponseContent( /// /// Destination Workspace /// + /// 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 DuplicateAsync( @@ -249,6 +433,7 @@ partial void ProcessDuplicateResponseContent( string title, int workspace, string? description = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.ProjectDuplicateRequest @@ -262,6 +447,7 @@ partial void ProcessDuplicateResponseContent( return await DuplicateAsync( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.Projects2Client.Get.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Projects2Client.Get.g.cs index 01a72da..8907996 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Projects2Client.Get.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Projects2Client.Get.g.cs @@ -14,6 +14,7 @@ public partial class Projects2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -50,11 +51,13 @@ partial void ProcessGetResponseContent( /// /// Default Value: 10 /// + /// 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 GetAsync( int id, int? membersLimit = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -70,25 +73,46 @@ partial void ProcessGetResponseContent( securityRequirements: s_GetSecurityRequirements, operationName: "GetAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{id}/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("members_limit", membersLimit?.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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{id}/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("members_limit", membersLimit?.ToString()) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -98,113 +122,272 @@ partial void ProcessGetResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - membersLimit: membersLimit); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + membersLimit: membersLimit); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/projects/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/projects/{id}/\"", + 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); - ProcessGetResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/projects/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.LseProjectResponse.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.LseProjectResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGetResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/projects/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/projects/{id}/\"", + 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); + ProcessGetResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.LseProjectResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.LseProjectResponse.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.Projects2Client.ImportPredictions.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Projects2Client.ImportPredictions.g.cs index 38344a4..a0dad78 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Projects2Client.ImportPredictions.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Projects2Client.ImportPredictions.g.cs @@ -14,6 +14,7 @@ public partial class Projects2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -48,12 +49,14 @@ partial void ProcessImportPredictionsResponseContent( ///
/// /// + /// 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 ImportPredictionsAsync( int id, global::System.Collections.Generic.IList request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -71,22 +74,43 @@ partial void ProcessImportPredictionsResponseContent( securityRequirements: s_ImportPredictionsSecurityRequirements, operationName: "ImportPredictionsAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{id}/import/predictions", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{id}/import/predictions", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,152 +120,311 @@ partial void ProcessImportPredictionsResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } - var __httpRequestContentBody = global::System.Text.Json.JsonSerializer.Serialize(request, request.GetType(), 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); - PrepareImportPredictionsRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - request: request); + var __httpRequestContentBody = global::System.Text.Json.JsonSerializer.Serialize(request, request.GetType(), JsonSerializerContext); + var __httpRequestContent = new global::System.Net.Http.StringContent( + content: __httpRequestContentBody, + encoding: global::System.Text.Encoding.UTF8, + mediaType: "application/json"); + __httpRequest.Content = __httpRequestContent; + global::LabelStudio.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); + PrepareImportPredictionsRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessImportPredictionsResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // - if ((int)__response.StatusCode == 400) + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_400 = null; - global::System.Exception? __exception_400 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ImportPredictions", + methodName: "ImportPredictionsAsync", + pathTemplate: "$\"/api/projects/{id}/import/predictions\"", + 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_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ImportPredictions", + methodName: "ImportPredictionsAsync", + pathTemplate: "$\"/api/projects/{id}/import/predictions\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else + + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ImportPredictions", + methodName: "ImportPredictionsAsync", + pathTemplate: "$\"/api/projects/{id}/import/predictions\"", + 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::LabelStudio.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::LabelStudio.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 (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); - ProcessImportPredictionsResponseContent( + response: __response); + ProcessImportPredictionsResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::LabelStudio.ApiProjectsImportPredictionsCreateResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ImportPredictions", + methodName: "ImportPredictionsAsync", + pathTemplate: "$\"/api/projects/{id}/import/predictions\"", + 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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ImportPredictions", + methodName: "ImportPredictionsAsync", + pathTemplate: "$\"/api/projects/{id}/import/predictions\"", + 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); + // + 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; + } - return - await global::LabelStudio.ApiProjectsImportPredictionsCreateResponse.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) - { - } + throw new global::LabelStudio.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 (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessImportPredictionsResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.ApiProjectsImportPredictionsCreateResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiProjectsImportPredictionsCreateResponse.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.Projects2Client.ImportTasks.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Projects2Client.ImportTasks.g.cs index 66b607c..af3e0e3 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Projects2Client.ImportTasks.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Projects2Client.ImportTasks.g.cs @@ -14,6 +14,7 @@ public partial class Projects2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -110,6 +111,7 @@ partial void ProcessImportTasksResponseContent( /// 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 ImportTasksAsync( @@ -119,6 +121,7 @@ partial void ProcessImportTasksResponseContent( bool? commitToProject = default, global::System.Collections.Generic.IList? preannotatedFromFields = default, bool? returnTaskIds = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -139,27 +142,48 @@ partial void ProcessImportTasksResponseContent( securityRequirements: s_ImportTasksSecurityRequirements, operationName: "ImportTasksAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{id}/import", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("commit_to_project", commitToProject?.ToString().ToLowerInvariant()) - .AddOptionalParameter("preannotated_from_fields", preannotatedFromFields, delimiter: ",", explode: true) - .AddOptionalParameter("return_task_ids", returnTaskIds?.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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{id}/import", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("commit_to_project", commitToProject?.ToString().ToLowerInvariant()) + .AddOptionalParameter("preannotated_from_fields", preannotatedFromFields, delimiter: ",", explode: true) + .AddOptionalParameter("return_task_ids", returnTaskIds?.ToString().ToLowerInvariant()) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -169,160 +193,319 @@ partial void ProcessImportTasksResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } - var __httpRequestContentBody = global::System.Text.Json.JsonSerializer.Serialize(request, request.GetType(), 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 = global::System.Text.Json.JsonSerializer.Serialize(request, request.GetType(), JsonSerializerContext); + var __httpRequestContent = new global::System.Net.Http.StringContent( + content: __httpRequestContentBody, + encoding: global::System.Text.Encoding.UTF8, + mediaType: "application/json"); + __httpRequest.Content = __httpRequestContent; + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareImportTasksRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - commitToProject: commitToProject, - id: id, - preannotatedFromFields: preannotatedFromFields, - returnTaskIds: returnTaskIds, - request: request); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareImportTasksRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + commitToProject: commitToProject, + id: id, + preannotatedFromFields: preannotatedFromFields, + returnTaskIds: returnTaskIds, + 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); - ProcessImportTasksResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Bad Request - if ((int)__response.StatusCode == 400) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_400 = null; - global::System.Exception? __exception_400 = null; - string? __value_400 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ImportTasks", + methodName: "ImportTasksAsync", + pathTemplate: "$\"/api/projects/{id}/import\"", + 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_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, 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_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ImportTasks", + methodName: "ImportTasksAsync", + pathTemplate: "$\"/api/projects/{id}/import\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ImportTasks", + methodName: "ImportTasksAsync", + pathTemplate: "$\"/api/projects/{id}/import\"", + 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::LabelStudio.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::LabelStudio.ApiException( - message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_400, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_400, - ResponseObject = __value_400, - 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); - ProcessImportTasksResponseContent( + response: __response); + ProcessImportTasksResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::LabelStudio.ApiProjectsImportCreateResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ImportTasks", + methodName: "ImportTasksAsync", + pathTemplate: "$\"/api/projects/{id}/import\"", + 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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ImportTasks", + methodName: "ImportTasksAsync", + pathTemplate: "$\"/api/projects/{id}/import\"", + 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); + // Bad Request + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + string? __value_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::LabelStudio.ApiProjectsImportCreateResponse.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_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::LabelStudio.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseObject = __value_400, + 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); + ProcessImportTasksResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.ApiProjectsImportCreateResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiProjectsImportCreateResponse.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.Projects2Client.List.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Projects2Client.List.g.cs index f41d7d5..238fa9e 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Projects2Client.List.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Projects2Client.List.g.cs @@ -14,6 +14,7 @@ public partial class Projects2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -82,6 +83,7 @@ partial void ProcessListResponseContent( /// /// /// + /// 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 ListAsync( @@ -97,6 +99,7 @@ partial void ProcessListResponseContent( string? state = default, string? title = default, double? workspaces = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -122,36 +125,57 @@ partial void ProcessListResponseContent( securityRequirements: s_ListSecurityRequirements, operationName: "ListAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/projects/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("archived", archived?.ToString().ToLowerInvariant()) - .AddOptionalParameter("filter", filter) - .AddOptionalParameter("ids", ids) - .AddOptionalParameter("include", include) - .AddOptionalParameter("members_limit", membersLimit?.ToString()) - .AddOptionalParameter("ordering", ordering) - .AddOptionalParameter("page", page?.ToString()) - .AddOptionalParameter("page_size", pageSize?.ToString()) - .AddOptionalParameter("search", search) - .AddOptionalParameter("state", state) - .AddOptionalParameter("title", title) - .AddOptionalParameter("workspaces", workspaces?.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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/projects/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("archived", archived?.ToString().ToLowerInvariant()) + .AddOptionalParameter("filter", filter) + .AddOptionalParameter("ids", ids) + .AddOptionalParameter("include", include) + .AddOptionalParameter("members_limit", membersLimit?.ToString()) + .AddOptionalParameter("ordering", ordering) + .AddOptionalParameter("page", page?.ToString()) + .AddOptionalParameter("page_size", pageSize?.ToString()) + .AddOptionalParameter("search", search) + .AddOptionalParameter("state", state) + .AddOptionalParameter("title", title) + .AddOptionalParameter("workspaces", workspaces?.ToString()) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -161,123 +185,282 @@ partial void ProcessListResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareListRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - archived: archived, - filter: filter, - ids: ids, - include: include, - membersLimit: membersLimit, - ordering: ordering, - page: page, - pageSize: pageSize, - search: search, - state: state, - title: title, - workspaces: workspaces); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareListRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + archived: archived, + filter: filter, + ids: ids, + include: include, + membersLimit: membersLimit, + ordering: ordering, + page: page, + pageSize: pageSize, + search: search, + state: state, + title: title, + workspaces: workspaces); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessListResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/projects/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/projects/\"", + 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); - ProcessListResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/projects/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.PaginatedAllRolesProjectListList.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.PaginatedAllRolesProjectListList.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessListResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/projects/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/projects/\"", + 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); + ProcessListResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.PaginatedAllRolesProjectListList.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.PaginatedAllRolesProjectListList.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.Projects2Client.ListCounts.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Projects2Client.ListCounts.g.cs index 6c13b91..d7a3e59 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Projects2Client.ListCounts.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Projects2Client.ListCounts.g.cs @@ -14,6 +14,7 @@ public partial class Projects2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -77,6 +78,7 @@ partial void ProcessListCountsResponseContent( /// /// /// + /// 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 ListCountsAsync( @@ -91,6 +93,7 @@ partial void ProcessListCountsResponseContent( string? state = default, string? title = default, double? workspaces = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -115,35 +118,56 @@ partial void ProcessListCountsResponseContent( securityRequirements: s_ListCountsSecurityRequirements, operationName: "ListCountsAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/projects/counts/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("archived", archived?.ToString().ToLowerInvariant()) - .AddOptionalParameter("filter", filter) - .AddOptionalParameter("ids", ids) - .AddOptionalParameter("include", include) - .AddOptionalParameter("ordering", ordering) - .AddOptionalParameter("page", page?.ToString()) - .AddOptionalParameter("page_size", pageSize?.ToString()) - .AddOptionalParameter("search", search) - .AddOptionalParameter("state", state) - .AddOptionalParameter("title", title) - .AddOptionalParameter("workspaces", workspaces?.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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/projects/counts/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("archived", archived?.ToString().ToLowerInvariant()) + .AddOptionalParameter("filter", filter) + .AddOptionalParameter("ids", ids) + .AddOptionalParameter("include", include) + .AddOptionalParameter("ordering", ordering) + .AddOptionalParameter("page", page?.ToString()) + .AddOptionalParameter("page_size", pageSize?.ToString()) + .AddOptionalParameter("search", search) + .AddOptionalParameter("state", state) + .AddOptionalParameter("title", title) + .AddOptionalParameter("workspaces", workspaces?.ToString()) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -153,122 +177,281 @@ partial void ProcessListCountsResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareListCountsRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - archived: archived, - filter: filter, - ids: ids, - include: include, - ordering: ordering, - page: page, - pageSize: pageSize, - search: search, - state: state, - title: title, - workspaces: workspaces); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareListCountsRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + archived: archived, + filter: filter, + ids: ids, + include: include, + ordering: ordering, + page: page, + pageSize: pageSize, + search: search, + state: state, + title: title, + workspaces: workspaces); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessListCountsResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListCounts", + methodName: "ListCountsAsync", + pathTemplate: "\"/api/projects/counts/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListCounts", + methodName: "ListCountsAsync", + pathTemplate: "\"/api/projects/counts/\"", + 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); - ProcessListCountsResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListCounts", + methodName: "ListCountsAsync", + pathTemplate: "\"/api/projects/counts/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.PaginatedLseProjectCountsList.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.PaginatedLseProjectCountsList.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessListCountsResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListCounts", + methodName: "ListCountsAsync", + pathTemplate: "\"/api/projects/counts/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListCounts", + methodName: "ListCountsAsync", + pathTemplate: "\"/api/projects/counts/\"", + 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); + ProcessListCountsResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.PaginatedLseProjectCountsList.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.PaginatedLseProjectCountsList.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.Projects2Client.ListUniqueAnnotators.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Projects2Client.ListUniqueAnnotators.g.cs index 880868f..ff84198 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Projects2Client.ListUniqueAnnotators.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Projects2Client.ListUniqueAnnotators.g.cs @@ -14,6 +14,7 @@ public partial class Projects2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,10 +46,12 @@ partial void ProcessListUniqueAnnotatorsResponseContent( /// Return unique users who have submitted annotations in the specified project. /// /// + /// 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> ListUniqueAnnotatorsAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -63,22 +66,43 @@ partial void ProcessListUniqueAnnotatorsResponseContent( securityRequirements: s_ListUniqueAnnotatorsSecurityRequirements, operationName: "ListUniqueAnnotatorsAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{id}/annotators/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{id}/annotators/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -88,112 +112,271 @@ partial void ProcessListUniqueAnnotatorsResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareListUniqueAnnotatorsRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareListUniqueAnnotatorsRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessListUniqueAnnotatorsResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListUniqueAnnotators", + methodName: "ListUniqueAnnotatorsAsync", + pathTemplate: "$\"/api/projects/{id}/annotators/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListUniqueAnnotators", + methodName: "ListUniqueAnnotatorsAsync", + pathTemplate: "$\"/api/projects/{id}/annotators/\"", + 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); - ProcessListUniqueAnnotatorsResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListUniqueAnnotators", + methodName: "ListUniqueAnnotatorsAsync", + pathTemplate: "$\"/api/projects/{id}/annotators/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessListUniqueAnnotatorsResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListUniqueAnnotators", + methodName: "ListUniqueAnnotatorsAsync", + pathTemplate: "$\"/api/projects/{id}/annotators/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListUniqueAnnotators", + methodName: "ListUniqueAnnotatorsAsync", + pathTemplate: "$\"/api/projects/{id}/annotators/\"", + 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); + ProcessListUniqueAnnotatorsResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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 + (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.Projects2Client.Update.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Projects2Client.Update.g.cs index 6d6ae56..84e10a7 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Projects2Client.Update.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Projects2Client.Update.g.cs @@ -16,6 +16,7 @@ public partial class Projects2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -55,6 +56,7 @@ partial void ProcessUpdateResponseContent( /// Default Value: 10 /// /// + /// 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 UpdateAsync( @@ -62,6 +64,7 @@ partial void ProcessUpdateResponseContent( global::LabelStudio.PatchedLseProjectUpdateRequest request, int? membersLimit = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -80,25 +83,46 @@ partial void ProcessUpdateResponseContent( securityRequirements: s_UpdateSecurityRequirements, operationName: "UpdateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{id}/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("members_limit", membersLimit?.ToString()) - ; - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{id}/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("members_limit", membersLimit?.ToString()) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -108,120 +132,279 @@ partial void ProcessUpdateResponseContent( __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); - PrepareUpdateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - membersLimit: membersLimit, - 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::LabelStudio.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); + PrepareUpdateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + membersLimit: membersLimit, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessUpdateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/projects/{id}/\"", + 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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/projects/{id}/\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessUpdateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/projects/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.LseProjectUpdate.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.LseProjectUpdate.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessUpdateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/projects/{id}/\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/projects/{id}/\"", + httpMethod: "PATCH", + 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); + ProcessUpdateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.LseProjectUpdate.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.LseProjectUpdate.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 project details
@@ -370,6 +553,7 @@ partial void ProcessUpdateResponseContent( /// /// Workspace /// + /// 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 UpdateAsync( @@ -422,6 +606,7 @@ partial void ProcessUpdateResponseContent( string? taskDataPassword = default, string? title = default, int? workspace = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.PatchedLseProjectUpdateRequest @@ -479,6 +664,7 @@ partial void ProcessUpdateResponseContent( id: id, membersLimit: membersLimit, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.Projects2Client.ValidateLabelConfig.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Projects2Client.ValidateLabelConfig.g.cs index ab569b3..873c509 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Projects2Client.ValidateLabelConfig.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Projects2Client.ValidateLabelConfig.g.cs @@ -14,6 +14,7 @@ public partial class Projects2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -48,12 +49,14 @@ partial void ProcessValidateLabelConfigResponseContent( ///
/// /// + /// 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 ValidateLabelConfigAsync( int id, global::LabelStudio.ProjectLabelConfigRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -71,22 +74,43 @@ partial void ProcessValidateLabelConfigResponseContent( securityRequirements: s_ValidateLabelConfigSecurityRequirements, operationName: "ValidateLabelConfigAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{id}/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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{id}/validate/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,119 +120,278 @@ partial void ProcessValidateLabelConfigResponseContent( __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); - PrepareValidateLabelConfigRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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::LabelStudio.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); + PrepareValidateLabelConfigRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessValidateLabelConfigResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ValidateLabelConfig", + methodName: "ValidateLabelConfigAsync", + pathTemplate: "$\"/api/projects/{id}/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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ValidateLabelConfig", + methodName: "ValidateLabelConfigAsync", + pathTemplate: "$\"/api/projects/{id}/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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessValidateLabelConfigResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ValidateLabelConfig", + methodName: "ValidateLabelConfigAsync", + pathTemplate: "$\"/api/projects/{id}/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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.ProjectLabelConfig.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.ProjectLabelConfig.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessValidateLabelConfigResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ValidateLabelConfig", + methodName: "ValidateLabelConfigAsync", + pathTemplate: "$\"/api/projects/{id}/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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ValidateLabelConfig", + methodName: "ValidateLabelConfigAsync", + pathTemplate: "$\"/api/projects/{id}/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); + } + + 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); + ProcessValidateLabelConfigResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.ProjectLabelConfig.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ProjectLabelConfig.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 project label config
@@ -218,11 +401,13 @@ partial void ProcessValidateLabelConfigResponseContent( /// /// Label config in XML format. See more about it in documentation /// + /// 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 ValidateLabelConfigAsync( int id, string labelConfig, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.ProjectLabelConfigRequest @@ -233,6 +418,7 @@ partial void ProcessValidateLabelConfigResponseContent( return await ValidateLabelConfigAsync( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.Projects2Client.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Projects2Client.g.cs index 1c1ed49..d1e63fa 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Projects2Client.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Projects2Client.g.cs @@ -30,6 +30,9 @@ public sealed partial class Projects2Client : global::LabelStudio.IProjects2Clie #if DEBUG = true; #endif + + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public Projects2Client( 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 Projects2Client. + /// 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 Projects2Client( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::LabelStudio.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::LabelStudio.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.Add.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.Add.g.cs index cd88f80..1d9c34c 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.Add.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.Add.g.cs @@ -14,6 +14,7 @@ public partial class ProjectsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -54,12 +55,14 @@ partial void ProcessAddResponseContent( ///
/// /// + /// 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 AddAsync( int id, global::LabelStudio.ProjectMemberRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -77,22 +80,43 @@ partial void ProcessAddResponseContent( securityRequirements: s_AddSecurityRequirements, operationName: "AddAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{id}/members/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{id}/members/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -102,119 +126,278 @@ partial void ProcessAddResponseContent( __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); - PrepareAddRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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::LabelStudio.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); + PrepareAddRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessAddResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Add", + methodName: "AddAsync", + pathTemplate: "$\"/api/projects/{id}/members/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Add", + methodName: "AddAsync", + pathTemplate: "$\"/api/projects/{id}/members/\"", + 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); - ProcessAddResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Add", + methodName: "AddAsync", + pathTemplate: "$\"/api/projects/{id}/members/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.ProjectMember.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.ProjectMember.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessAddResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Add", + methodName: "AddAsync", + pathTemplate: "$\"/api/projects/{id}/members/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Add", + methodName: "AddAsync", + pathTemplate: "$\"/api/projects/{id}/members/\"", + 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); + ProcessAddResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.ProjectMember.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ProjectMember.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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(); + } } /// /// ✨ Add project member
@@ -228,11 +411,13 @@ partial void ProcessAddResponseContent( ///
/// /// + /// 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 AddAsync( int id, int user, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.ProjectMemberRequest @@ -243,6 +428,7 @@ partial void ProcessAddResponseContent( return await AddAsync( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.ApiProjectsReimportsRetrieve.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.ApiProjectsReimportsRetrieve.g.cs index 4dc0f58..5ff9a22 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.ApiProjectsReimportsRetrieve.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.ApiProjectsReimportsRetrieve.g.cs @@ -14,6 +14,7 @@ public partial class ProjectsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -57,11 +58,13 @@ partial void ProcessApiProjectsReimportsRetrieveResponseContent( /// /// /// + /// 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 ApiProjectsReimportsRetrieveAsync( int id, int reimportPk, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -77,22 +80,43 @@ partial void ProcessApiProjectsReimportsRetrieveResponseContent( securityRequirements: s_ApiProjectsReimportsRetrieveSecurityRequirements, operationName: "ApiProjectsReimportsRetrieveAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{id}/reimports/{reimportPk}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{id}/reimports/{reimportPk}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,113 +126,272 @@ partial void ProcessApiProjectsReimportsRetrieveResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareApiProjectsReimportsRetrieveRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - reimportPk: reimportPk); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareApiProjectsReimportsRetrieveRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + reimportPk: reimportPk); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiProjectsReimportsRetrieveResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiProjectsReimportsRetrieve", + methodName: "ApiProjectsReimportsRetrieveAsync", + pathTemplate: "$\"/api/projects/{id}/reimports/{reimportPk}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiProjectsReimportsRetrieve", + methodName: "ApiProjectsReimportsRetrieveAsync", + pathTemplate: "$\"/api/projects/{id}/reimports/{reimportPk}/\"", + 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); - ProcessApiProjectsReimportsRetrieveResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiProjectsReimportsRetrieve", + methodName: "ApiProjectsReimportsRetrieveAsync", + pathTemplate: "$\"/api/projects/{id}/reimports/{reimportPk}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.ProjectReimport.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.ProjectReimport.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessApiProjectsReimportsRetrieveResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiProjectsReimportsRetrieve", + methodName: "ApiProjectsReimportsRetrieveAsync", + pathTemplate: "$\"/api/projects/{id}/reimports/{reimportPk}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiProjectsReimportsRetrieve", + methodName: "ApiProjectsReimportsRetrieveAsync", + pathTemplate: "$\"/api/projects/{id}/reimports/{reimportPk}/\"", + 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); + ProcessApiProjectsReimportsRetrieveResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.ProjectReimport.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ProjectReimport.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.ProjectsClient.ApiProjectsTasksList.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.ApiProjectsTasksList.g.cs index 75a1252..c220b43 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.ApiProjectsTasksList.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.ApiProjectsTasksList.g.cs @@ -14,6 +14,7 @@ public partial class ProjectsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -58,6 +59,7 @@ partial void ProcessApiProjectsTasksListResponseContent( /// /// /// + /// 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> ApiProjectsTasksListAsync( @@ -65,6 +67,7 @@ partial void ProcessApiProjectsTasksListResponseContent( string? ordering = default, int? page = default, int? pageSize = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -82,27 +85,48 @@ partial void ProcessApiProjectsTasksListResponseContent( securityRequirements: s_ApiProjectsTasksListSecurityRequirements, operationName: "ApiProjectsTasksListAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{id}/tasks/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("ordering", ordering) - .AddOptionalParameter("page", page?.ToString()) - .AddOptionalParameter("page_size", pageSize?.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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{id}/tasks/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("ordering", ordering) + .AddOptionalParameter("page", page?.ToString()) + .AddOptionalParameter("page_size", pageSize?.ToString()) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -112,115 +136,274 @@ partial void ProcessApiProjectsTasksListResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareApiProjectsTasksListRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - ordering: ordering, - page: page, - pageSize: pageSize); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareApiProjectsTasksListRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + ordering: ordering, + page: page, + pageSize: pageSize); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiProjectsTasksListResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiProjectsTasksList", + methodName: "ApiProjectsTasksListAsync", + pathTemplate: "$\"/api/projects/{id}/tasks/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiProjectsTasksList", + methodName: "ApiProjectsTasksListAsync", + pathTemplate: "$\"/api/projects/{id}/tasks/\"", + 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); - ProcessApiProjectsTasksListResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiProjectsTasksList", + methodName: "ApiProjectsTasksListAsync", + pathTemplate: "$\"/api/projects/{id}/tasks/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessApiProjectsTasksListResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiProjectsTasksList", + methodName: "ApiProjectsTasksListAsync", + pathTemplate: "$\"/api/projects/{id}/tasks/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiProjectsTasksList", + methodName: "ApiProjectsTasksListAsync", + pathTemplate: "$\"/api/projects/{id}/tasks/\"", + 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); + ProcessApiProjectsTasksListResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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 + (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.ProjectsClient.ApiProjectsValidateCreate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.ApiProjectsValidateCreate.g.cs index 0a9d887..0187f18 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.ApiProjectsValidateCreate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.ApiProjectsValidateCreate.g.cs @@ -14,6 +14,7 @@ public partial class ProjectsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -49,11 +50,13 @@ partial void ProcessApiProjectsValidateCreateResponse( /// Validate an arbitrary labeling configuration. /// /// + /// 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 ApiProjectsValidateCreateAsync( global::LabelStudio.ProjectLabelConfigRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -70,22 +73,43 @@ partial void ProcessApiProjectsValidateCreateResponse( securityRequirements: s_ApiProjectsValidateCreateSecurityRequirements, operationName: "ApiProjectsValidateCreateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/projects/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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/projects/validate/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,135 +119,294 @@ partial void ProcessApiProjectsValidateCreateResponse( __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); - PrepareApiProjectsValidateCreateRequest( - 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::LabelStudio.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); + PrepareApiProjectsValidateCreateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiProjectsValidateCreateResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // - if ((int)__response.StatusCode == 400) + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_400 = null; - global::System.Exception? __exception_400 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiProjectsValidateCreate", + methodName: "ApiProjectsValidateCreateAsync", + pathTemplate: "\"/api/projects/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 + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiProjectsValidateCreate", + methodName: "ApiProjectsValidateCreateAsync", + pathTemplate: "\"/api/projects/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; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else + + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiProjectsValidateCreate", + methodName: "ApiProjectsValidateCreateAsync", + pathTemplate: "\"/api/projects/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::LabelStudio.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::LabelStudio.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 (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); - - try - { - __response.EnsureSuccessStatusCode(); - - } - catch (global::System.Exception __ex) + response: __response); + ProcessApiProjectsValidateCreateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiProjectsValidateCreate", + methodName: "ApiProjectsValidateCreateAsync", + pathTemplate: "\"/api/projects/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 + else { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiProjectsValidateCreate", + methodName: "ApiProjectsValidateCreateAsync", + pathTemplate: "\"/api/projects/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) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + // + 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::LabelStudio.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 (__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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 label config
@@ -232,10 +415,12 @@ partial void ProcessApiProjectsValidateCreateResponse( /// /// Label config in XML format. See more about it in documentation /// + /// 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 ApiProjectsValidateCreateAsync( string labelConfig, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.ProjectLabelConfigRequest @@ -245,6 +430,7 @@ partial void ProcessApiProjectsValidateCreateResponse( await ApiProjectsValidateCreateAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.CheckFunction.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.CheckFunction.g.cs index d067b0c..f072e9b 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.CheckFunction.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.CheckFunction.g.cs @@ -14,6 +14,7 @@ public partial class ProjectsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -49,12 +50,14 @@ partial void ProcessCheckFunctionResponse( ///
/// /// + /// 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 CheckFunctionAsync( int id, global::LabelStudio.CheckMatchingFunctionRequestRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -72,22 +75,43 @@ partial void ProcessCheckFunctionResponse( securityRequirements: s_CheckFunctionSecurityRequirements, operationName: "CheckFunctionAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{id}/check-function", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{id}/check-function", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -97,103 +121,262 @@ partial void ProcessCheckFunctionResponse( __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); - PrepareCheckFunctionRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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::LabelStudio.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); + PrepareCheckFunctionRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCheckFunctionResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CheckFunction", + methodName: "CheckFunctionAsync", + pathTemplate: "$\"/api/projects/{id}/check-function\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CheckFunction", + methodName: "CheckFunctionAsync", + pathTemplate: "$\"/api/projects/{id}/check-function\"", + 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); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CheckFunction", + methodName: "CheckFunctionAsync", + pathTemplate: "$\"/api/projects/{id}/check-function\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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(); + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessCheckFunctionResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CheckFunction", + methodName: "CheckFunctionAsync", + pathTemplate: "$\"/api/projects/{id}/check-function\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CheckFunction", + methodName: "CheckFunctionAsync", + pathTemplate: "$\"/api/projects/{id}/check-function\"", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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(); + } } /// /// ✨ Check custom matching function code
@@ -207,11 +390,13 @@ partial void ProcessCheckFunctionResponse( ///
/// /// + /// 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 CheckFunctionAsync( int id, string code, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.CheckMatchingFunctionRequestRequest @@ -222,6 +407,7 @@ partial void ProcessCheckFunctionResponse( await CheckFunctionAsync( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.Create2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.Create2.g.cs index f3c0f96..cf440d7 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.Create2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.Create2.g.cs @@ -14,6 +14,7 @@ public partial class ProjectsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -54,12 +55,14 @@ partial void ProcessCreate2ResponseContent( /// /// /// + /// 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 Create2Async( int id, global::LabelStudio.LseProjectParamsRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -77,22 +80,43 @@ partial void ProcessCreate2ResponseContent( securityRequirements: s_Create2SecurityRequirements, operationName: "Create2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{id}/project-extra-params/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{id}/project-extra-params/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -102,119 +126,278 @@ partial void ProcessCreate2ResponseContent( __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); - PrepareCreate2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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::LabelStudio.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); + PrepareCreate2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreate2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "$\"/api/projects/{id}/project-extra-params/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "$\"/api/projects/{id}/project-extra-params/\"", + 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); - ProcessCreate2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "$\"/api/projects/{id}/project-extra-params/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.LseProjectParams.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.LseProjectParams.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessCreate2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "$\"/api/projects/{id}/project-extra-params/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "$\"/api/projects/{id}/project-extra-params/\"", + 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); + ProcessCreate2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.LseProjectParams.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.LseProjectParams.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 annotator weights for statistics
@@ -233,12 +416,14 @@ partial void ProcessCreate2ResponseContent( /// /// If categorical variables are used in labeling (e.g. choices), Cohen's Kappa statistic is computed to measure inter-rater reliability instead of basic agreement /// + /// 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 Create2Async( int id, global::System.Collections.Generic.Dictionary? annotatorParams = default, bool? useKappa = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.LseProjectParamsRequest @@ -250,6 +435,7 @@ partial void ProcessCreate2ResponseContent( return await Create2Async( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.Delete2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.Delete2.g.cs index b884902..18e02a1 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.Delete2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.Delete2.g.cs @@ -14,6 +14,7 @@ public partial class ProjectsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -75,6 +76,7 @@ partial void ProcessDelete2ResponseContent( /// /// /// + /// 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 Delete2Async( @@ -87,6 +89,7 @@ partial void ProcessDelete2ResponseContent( string? role = default, string? search = default, string? tags = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -109,32 +112,53 @@ partial void ProcessDelete2ResponseContent( securityRequirements: s_Delete2SecurityRequirements, operationName: "Delete2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{id}/members/bulk/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("all", all?.ToString().ToLowerInvariant()) - .AddOptionalParameter("excluded", excluded) - .AddOptionalParameter("included", included) - .AddOptionalParameter("last_activity__gte", lastActivityGte) - .AddOptionalParameter("last_activity__lte", lastActivityLte) - .AddOptionalParameter("role", role) - .AddOptionalParameter("search", search) - .AddOptionalParameter("tags", tags) - ; - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{id}/members/bulk/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("all", all?.ToString().ToLowerInvariant()) + .AddOptionalParameter("excluded", excluded) + .AddOptionalParameter("included", included) + .AddOptionalParameter("last_activity__gte", lastActivityGte) + .AddOptionalParameter("last_activity__lte", lastActivityLte) + .AddOptionalParameter("role", role) + .AddOptionalParameter("search", search) + .AddOptionalParameter("tags", tags) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -144,120 +168,279 @@ partial void ProcessDelete2ResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDelete2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - all: all, - excluded: excluded, - id: id, - included: included, - lastActivityGte: lastActivityGte, - lastActivityLte: lastActivityLte, - role: role, - search: search, - tags: tags); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDelete2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + all: all, + excluded: excluded, + id: id, + included: included, + lastActivityGte: lastActivityGte, + lastActivityLte: lastActivityLte, + role: role, + search: search, + tags: tags); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessDelete2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/projects/{id}/members/bulk/\"", + 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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/projects/{id}/members/bulk/\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessDelete2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/projects/{id}/members/bulk/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.ApiProjectsMembersBulkDestroyResponse.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.ApiProjectsMembersBulkDestroyResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessDelete2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/projects/{id}/members/bulk/\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/projects/{id}/members/bulk/\"", + httpMethod: "DELETE", + 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); + ProcessDelete2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.ApiProjectsMembersBulkDestroyResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiProjectsMembersBulkDestroyResponse.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.ProjectsClient.DeployFunction.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.DeployFunction.g.cs index 8dbb78e..1300887 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.DeployFunction.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.DeployFunction.g.cs @@ -14,6 +14,7 @@ public partial class ProjectsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -49,12 +50,14 @@ partial void ProcessDeployFunctionResponse( ///
/// /// + /// 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 DeployFunctionAsync( int id, global::LabelStudio.CustomFunctionCodeRequestRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -72,22 +75,43 @@ partial void ProcessDeployFunctionResponse( securityRequirements: s_DeployFunctionSecurityRequirements, operationName: "DeployFunctionAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{id}/custom-function", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{id}/custom-function", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -97,136 +121,295 @@ partial void ProcessDeployFunctionResponse( __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::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDeployFunctionRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - request: request); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDeployFunctionRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + 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); - ProcessDeployFunctionResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // - if ((int)__response.StatusCode == 500) + 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; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeployFunction", + methodName: "DeployFunctionAsync", + pathTemplate: "$\"/api/projects/{id}/custom-function\"", + 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) { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeployFunction", + methodName: "DeployFunctionAsync", + pathTemplate: "$\"/api/projects/{id}/custom-function\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else + + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeployFunction", + methodName: "DeployFunctionAsync", + pathTemplate: "$\"/api/projects/{id}/custom-function\"", + 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::LabelStudio.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::LabelStudio.ApiException( - message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_500, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_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); - - try - { - __response.EnsureSuccessStatusCode(); - - } - catch (global::System.Exception __ex) + response: __response); + ProcessDeployFunctionResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeployFunction", + methodName: "DeployFunctionAsync", + pathTemplate: "$\"/api/projects/{id}/custom-function\"", + 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 + else { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeployFunction", + methodName: "DeployFunctionAsync", + pathTemplate: "$\"/api/projects/{id}/custom-function\"", + 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) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + // + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } + + throw new global::LabelStudio.ApiException( + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + statusCode: __response.StatusCode) + { + ResponseBody = __content_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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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(); + } } /// /// ✨ Deploy custom metric function
@@ -240,11 +423,13 @@ partial void ProcessDeployFunctionResponse( ///
/// /// + /// 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 DeployFunctionAsync( int id, string code, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.CustomFunctionCodeRequestRequest @@ -255,6 +440,7 @@ partial void ProcessDeployFunctionResponse( await DeployFunctionAsync( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.Get3.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.Get3.g.cs index 266b4c7..f79eabd 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.Get3.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.Get3.g.cs @@ -14,6 +14,7 @@ public partial class ProjectsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,10 +52,12 @@ partial void ProcessGet3ResponseContent( /// Get the current metrics configuration for a project. /// /// + /// 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 Get3Async( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -69,22 +72,43 @@ partial void ProcessGet3ResponseContent( securityRequirements: s_Get3SecurityRequirements, operationName: "Get3Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{id}/metricparam/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{id}/metricparam/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,112 +118,271 @@ partial void ProcessGet3ResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGet3Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGet3Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGet3Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get3", + methodName: "Get3Async", + pathTemplate: "$\"/api/projects/{id}/metricparam/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get3", + methodName: "Get3Async", + pathTemplate: "$\"/api/projects/{id}/metricparam/\"", + 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); - ProcessGet3ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get3", + methodName: "Get3Async", + pathTemplate: "$\"/api/projects/{id}/metricparam/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.MetricParam.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.MetricParam.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGet3Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get3", + methodName: "Get3Async", + pathTemplate: "$\"/api/projects/{id}/metricparam/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get3", + methodName: "Get3Async", + pathTemplate: "$\"/api/projects/{id}/metricparam/\"", + 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); + ProcessGet3ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.MetricParam.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.MetricParam.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.ProjectsClient.Get4.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.Get4.g.cs index ff13100..9ffb115 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.Get4.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.Get4.g.cs @@ -14,6 +14,7 @@ public partial class ProjectsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,10 +52,12 @@ partial void ProcessGet4ResponseContent( /// Retrieve the annotator weights for statistics and Cohen's Kappa for a specific project. Affects dashboard-members stats, but old and unused. /// /// + /// 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 Get4Async( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -69,22 +72,43 @@ partial void ProcessGet4ResponseContent( securityRequirements: s_Get4SecurityRequirements, operationName: "Get4Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{id}/project-extra-params/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{id}/project-extra-params/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,112 +118,271 @@ partial void ProcessGet4ResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGet4Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGet4Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGet4Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get4", + methodName: "Get4Async", + pathTemplate: "$\"/api/projects/{id}/project-extra-params/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get4", + methodName: "Get4Async", + pathTemplate: "$\"/api/projects/{id}/project-extra-params/\"", + 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); - ProcessGet4ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get4", + methodName: "Get4Async", + pathTemplate: "$\"/api/projects/{id}/project-extra-params/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.LseProjectParams.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.LseProjectParams.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGet4Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get4", + methodName: "Get4Async", + pathTemplate: "$\"/api/projects/{id}/project-extra-params/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get4", + methodName: "Get4Async", + pathTemplate: "$\"/api/projects/{id}/project-extra-params/\"", + 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); + ProcessGet4ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.LseProjectParams.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.LseProjectParams.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.ProjectsClient.GetFunction.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.GetFunction.g.cs index 5bab957..50b533f 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.GetFunction.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.GetFunction.g.cs @@ -14,6 +14,7 @@ public partial class ProjectsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,10 +52,12 @@ partial void ProcessGetFunctionResponseContent( /// Get the custom metric function code for this project. The server routes to the active cloud provider (AWS Lambda or GCP Cloud Functions) based on the CUSTOM_METRIC_PROVIDER setting. /// /// + /// 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 GetFunctionAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -69,22 +72,43 @@ partial void ProcessGetFunctionResponseContent( securityRequirements: s_GetFunctionSecurityRequirements, operationName: "GetFunctionAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{id}/custom-function", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{id}/custom-function", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,112 +118,271 @@ partial void ProcessGetFunctionResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetFunctionRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetFunctionRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetFunctionResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetFunction", + methodName: "GetFunctionAsync", + pathTemplate: "$\"/api/projects/{id}/custom-function\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetFunction", + methodName: "GetFunctionAsync", + pathTemplate: "$\"/api/projects/{id}/custom-function\"", + 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); - ProcessGetFunctionResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetFunction", + methodName: "GetFunctionAsync", + pathTemplate: "$\"/api/projects/{id}/custom-function\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.ApiProjectsCustomFunctionRetrieveResponse.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.ApiProjectsCustomFunctionRetrieveResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGetFunctionResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetFunction", + methodName: "GetFunctionAsync", + pathTemplate: "$\"/api/projects/{id}/custom-function\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetFunction", + methodName: "GetFunctionAsync", + pathTemplate: "$\"/api/projects/{id}/custom-function\"", + 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); + ProcessGetFunctionResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.ApiProjectsCustomFunctionRetrieveResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiProjectsCustomFunctionRetrieveResponse.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.ProjectsClient.GetFunctionLogs.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.GetFunctionLogs.g.cs index a53a137..46951a1 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.GetFunctionLogs.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.GetFunctionLogs.g.cs @@ -14,6 +14,7 @@ public partial class ProjectsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -62,6 +63,7 @@ partial void ProcessGetFunctionLogsResponseContent( /// Default Value: 100 /// /// + /// 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 GetFunctionLogsAsync( @@ -69,6 +71,7 @@ partial void ProcessGetFunctionLogsResponseContent( string? endDate = default, int? limit = default, string? startDate = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -86,27 +89,48 @@ partial void ProcessGetFunctionLogsResponseContent( securityRequirements: s_GetFunctionLogsSecurityRequirements, operationName: "GetFunctionLogsAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{id}/custom-function-logs", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("end_date", endDate) - .AddOptionalParameter("limit", limit?.ToString()) - .AddOptionalParameter("start_date", startDate) - ; - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{id}/custom-function-logs", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("end_date", endDate) + .AddOptionalParameter("limit", limit?.ToString()) + .AddOptionalParameter("start_date", startDate) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -116,111 +140,270 @@ partial void ProcessGetFunctionLogsResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetFunctionLogsRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - endDate: endDate, - id: id, - limit: limit, - startDate: startDate); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetFunctionLogsRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + endDate: endDate, + id: id, + limit: limit, + startDate: startDate); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetFunctionLogsResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetFunctionLogs", + methodName: "GetFunctionLogsAsync", + pathTemplate: "$\"/api/projects/{id}/custom-function-logs\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetFunctionLogs", + methodName: "GetFunctionLogsAsync", + pathTemplate: "$\"/api/projects/{id}/custom-function-logs\"", + 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); - ProcessGetFunctionLogsResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetFunctionLogs", + methodName: "GetFunctionLogsAsync", + pathTemplate: "$\"/api/projects/{id}/custom-function-logs\"", + 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::LabelStudio.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::LabelStudio.ApiException( - message: __content ?? __response.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); + ProcessGetFunctionLogsResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetFunctionLogs", + methodName: "GetFunctionLogsAsync", + pathTemplate: "$\"/api/projects/{id}/custom-function-logs\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetFunctionLogs", + methodName: "GetFunctionLogsAsync", + pathTemplate: "$\"/api/projects/{id}/custom-function-logs\"", + 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); + ProcessGetFunctionLogsResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return __content; + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.ProjectsClient.GetGcpFunction.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.GetGcpFunction.g.cs index 045dca3..8542ded 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.GetGcpFunction.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.GetGcpFunction.g.cs @@ -14,6 +14,7 @@ public partial class ProjectsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,10 +52,12 @@ partial void ProcessGetGcpFunctionResponseContent( /// Get the GCP Cloud Function code for the custom metric configured for this project. /// /// + /// 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 GetGcpFunctionAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -69,22 +72,43 @@ partial void ProcessGetGcpFunctionResponseContent( securityRequirements: s_GetGcpFunctionSecurityRequirements, operationName: "GetGcpFunctionAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{id}/gcp-custom-function", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{id}/gcp-custom-function", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,112 +118,271 @@ partial void ProcessGetGcpFunctionResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetGcpFunctionRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetGcpFunctionRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetGcpFunctionResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetGcpFunction", + methodName: "GetGcpFunctionAsync", + pathTemplate: "$\"/api/projects/{id}/gcp-custom-function\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetGcpFunction", + methodName: "GetGcpFunctionAsync", + pathTemplate: "$\"/api/projects/{id}/gcp-custom-function\"", + 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); - ProcessGetGcpFunctionResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetGcpFunction", + methodName: "GetGcpFunctionAsync", + pathTemplate: "$\"/api/projects/{id}/gcp-custom-function\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.ApiProjectsGcpCustomFunctionRetrieveResponse.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.ApiProjectsGcpCustomFunctionRetrieveResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGetGcpFunctionResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetGcpFunction", + methodName: "GetGcpFunctionAsync", + pathTemplate: "$\"/api/projects/{id}/gcp-custom-function\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetGcpFunction", + methodName: "GetGcpFunctionAsync", + pathTemplate: "$\"/api/projects/{id}/gcp-custom-function\"", + 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); + ProcessGetGcpFunctionResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.ApiProjectsGcpCustomFunctionRetrieveResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiProjectsGcpCustomFunctionRetrieveResponse.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.ProjectsClient.GetLambda.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.GetLambda.g.cs index 0adcdd6..687db36 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.GetLambda.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.GetLambda.g.cs @@ -14,6 +14,7 @@ public partial class ProjectsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,10 +52,12 @@ partial void ProcessGetLambdaResponseContent( /// Get the AWS Lambda code for the custom metric configured for this project. /// /// + /// 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 GetLambdaAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -69,22 +72,43 @@ partial void ProcessGetLambdaResponseContent( securityRequirements: s_GetLambdaSecurityRequirements, operationName: "GetLambdaAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{id}/aws-custom-function", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{id}/aws-custom-function", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,112 +118,271 @@ partial void ProcessGetLambdaResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetLambdaRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetLambdaRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetLambdaResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetLambda", + methodName: "GetLambdaAsync", + pathTemplate: "$\"/api/projects/{id}/aws-custom-function\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetLambda", + methodName: "GetLambdaAsync", + pathTemplate: "$\"/api/projects/{id}/aws-custom-function\"", + 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); - ProcessGetLambdaResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetLambda", + methodName: "GetLambdaAsync", + pathTemplate: "$\"/api/projects/{id}/aws-custom-function\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.ApiProjectsAwsCustomFunctionRetrieveResponse.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.ApiProjectsAwsCustomFunctionRetrieveResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGetLambdaResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetLambda", + methodName: "GetLambdaAsync", + pathTemplate: "$\"/api/projects/{id}/aws-custom-function\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetLambda", + methodName: "GetLambdaAsync", + pathTemplate: "$\"/api/projects/{id}/aws-custom-function\"", + 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); + ProcessGetLambdaResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.ApiProjectsAwsCustomFunctionRetrieveResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiProjectsAwsCustomFunctionRetrieveResponse.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.ProjectsClient.List2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.List2.g.cs index 7163e72..32322ee 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.List2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.List2.g.cs @@ -14,6 +14,7 @@ public partial class ProjectsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -93,6 +94,7 @@ partial void ProcessList2ResponseContent( /// /// /// + /// 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 List2Async( @@ -109,6 +111,7 @@ partial void ProcessList2ResponseContent( string? search = default, string? tags = default, bool? withDeleted = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -135,36 +138,57 @@ partial void ProcessList2ResponseContent( securityRequirements: s_List2SecurityRequirements, operationName: "List2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{id}/members/paginated/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("ids", ids) - .AddOptionalParameter("implicit", @implicit?.ToString().ToLowerInvariant()) - .AddOptionalParameter("last_activity__gte", lastActivityGte?.ToString("yyyy-MM-ddTHH:mm:ssZ")) - .AddOptionalParameter("last_activity__lte", lastActivityLte?.ToString("yyyy-MM-ddTHH:mm:ssZ")) - .AddOptionalParameter("no_annotators", noAnnotators?.ToString().ToLowerInvariant()) - .AddOptionalParameter("ordering", ordering) - .AddOptionalParameter("page", page?.ToString()) - .AddOptionalParameter("page_size", pageSize?.ToString()) - .AddOptionalParameter("role", role) - .AddOptionalParameter("search", search) - .AddOptionalParameter("tags", tags) - .AddOptionalParameter("with_deleted", withDeleted?.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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{id}/members/paginated/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("ids", ids) + .AddOptionalParameter("implicit", @implicit?.ToString().ToLowerInvariant()) + .AddOptionalParameter("last_activity__gte", lastActivityGte?.ToString("yyyy-MM-ddTHH:mm:ssZ")) + .AddOptionalParameter("last_activity__lte", lastActivityLte?.ToString("yyyy-MM-ddTHH:mm:ssZ")) + .AddOptionalParameter("no_annotators", noAnnotators?.ToString().ToLowerInvariant()) + .AddOptionalParameter("ordering", ordering) + .AddOptionalParameter("page", page?.ToString()) + .AddOptionalParameter("page_size", pageSize?.ToString()) + .AddOptionalParameter("role", role) + .AddOptionalParameter("search", search) + .AddOptionalParameter("tags", tags) + .AddOptionalParameter("with_deleted", withDeleted?.ToString().ToLowerInvariant()) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -174,124 +198,283 @@ partial void ProcessList2ResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareList2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - ids: ids, - @implicit: @implicit, - lastActivityGte: lastActivityGte, - lastActivityLte: lastActivityLte, - noAnnotators: noAnnotators, - ordering: ordering, - page: page, - pageSize: pageSize, - role: role, - search: search, - tags: tags, - withDeleted: withDeleted); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareList2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + ids: ids, + @implicit: @implicit, + lastActivityGte: lastActivityGte, + lastActivityLte: lastActivityLte, + noAnnotators: noAnnotators, + ordering: ordering, + page: page, + pageSize: pageSize, + role: role, + search: search, + tags: tags, + withDeleted: withDeleted); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessList2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "$\"/api/projects/{id}/members/paginated/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "$\"/api/projects/{id}/members/paginated/\"", + 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); - ProcessList2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "$\"/api/projects/{id}/members/paginated/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.PaginatedPaginatedProjectMemberList.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.PaginatedPaginatedProjectMemberList.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessList2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "$\"/api/projects/{id}/members/paginated/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "$\"/api/projects/{id}/members/paginated/\"", + 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); + ProcessList2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.PaginatedPaginatedProjectMemberList.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.PaginatedPaginatedProjectMemberList.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.ProjectsClient.Post.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.Post.g.cs index 1723c35..14ea9e1 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.Post.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.Post.g.cs @@ -14,6 +14,7 @@ public partial class ProjectsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -69,6 +70,7 @@ partial void ProcessPostResponseContent( /// /// /// + /// 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 PostAsync( @@ -80,6 +82,7 @@ partial void ProcessPostResponseContent( string? role = default, string? search = default, string? tags = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -102,29 +105,50 @@ partial void ProcessPostResponseContent( securityRequirements: s_PostSecurityRequirements, operationName: "PostAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{id}/members/bulk/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("last_activity__gte", lastActivityGte) - .AddOptionalParameter("last_activity__lte", lastActivityLte) - .AddOptionalParameter("role", role) - .AddOptionalParameter("search", search) - .AddOptionalParameter("tags", tags) - ; - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{id}/members/bulk/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("last_activity__gte", lastActivityGte) + .AddOptionalParameter("last_activity__lte", lastActivityLte) + .AddOptionalParameter("role", role) + .AddOptionalParameter("search", search) + .AddOptionalParameter("tags", tags) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -134,124 +158,283 @@ partial void ProcessPostResponseContent( __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::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PreparePostRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - lastActivityGte: lastActivityGte, - lastActivityLte: lastActivityLte, - role: role, - search: search, - tags: tags, - request: request); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PreparePostRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + lastActivityGte: lastActivityGte, + lastActivityLte: lastActivityLte, + role: role, + search: search, + tags: tags, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessPostResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Post", + methodName: "PostAsync", + pathTemplate: "$\"/api/projects/{id}/members/bulk/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Post", + methodName: "PostAsync", + pathTemplate: "$\"/api/projects/{id}/members/bulk/\"", + 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); - ProcessPostResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Post", + methodName: "PostAsync", + pathTemplate: "$\"/api/projects/{id}/members/bulk/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.ApiProjectsMembersBulkCreateResponse.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.ApiProjectsMembersBulkCreateResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessPostResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Post", + methodName: "PostAsync", + pathTemplate: "$\"/api/projects/{id}/members/bulk/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Post", + methodName: "PostAsync", + pathTemplate: "$\"/api/projects/{id}/members/bulk/\"", + 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); + ProcessPostResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.ApiProjectsMembersBulkCreateResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiProjectsMembersBulkCreateResponse.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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(); + } } /// /// ✨ Bulk assign project members
@@ -281,6 +464,7 @@ partial void ProcessPostResponseContent( /// /// Member roles /// + /// 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 PostAsync( @@ -294,6 +478,7 @@ partial void ProcessPostResponseContent( global::System.Collections.Generic.IList? excluded = default, global::System.Collections.Generic.IList? included = default, global::System.Collections.Generic.IList? roles = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.ProjectMemberBulkAssignRequest @@ -312,6 +497,7 @@ partial void ProcessPostResponseContent( search: search, tags: tags, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.Remove.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.Remove.g.cs index 4895929..e7b639c 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.Remove.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.Remove.g.cs @@ -14,6 +14,7 @@ public partial class ProjectsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -49,11 +50,13 @@ partial void ProcessRemoveResponse( ///
/// /// + /// 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 RemoveAsync( int id, int? user = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -69,25 +72,46 @@ partial void ProcessRemoveResponse( securityRequirements: s_RemoveSecurityRequirements, operationName: "RemoveAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{id}/members/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("user", user?.ToString()) - ; - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{id}/members/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("user", user?.ToString()) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -97,97 +121,256 @@ partial void ProcessRemoveResponse( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareRemoveRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - user: user); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareRemoveRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + user: user); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Remove", + methodName: "RemoveAsync", + pathTemplate: "$\"/api/projects/{id}/members/\"", + 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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Remove", + methodName: "RemoveAsync", + pathTemplate: "$\"/api/projects/{id}/members/\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessRemoveResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Remove", + methodName: "RemoveAsync", + pathTemplate: "$\"/api/projects/{id}/members/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessRemoveResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Remove", + methodName: "RemoveAsync", + pathTemplate: "$\"/api/projects/{id}/members/\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Remove", + methodName: "RemoveAsync", + pathTemplate: "$\"/api/projects/{id}/members/\"", + httpMethod: "DELETE", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.ProjectsClient.Update2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.Update2.g.cs index 5096523..8f02f67 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.Update2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.Update2.g.cs @@ -16,6 +16,7 @@ public partial class ProjectsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -56,12 +57,14 @@ partial void ProcessUpdate2ResponseContent( /// /// /// + /// 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 Update2Async( int id, global::LabelStudio.MetricParamUpdateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -79,22 +82,43 @@ partial void ProcessUpdate2ResponseContent( securityRequirements: s_Update2SecurityRequirements, operationName: "Update2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{id}/metricparam/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{id}/metricparam/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -104,119 +128,278 @@ partial void ProcessUpdate2ResponseContent( __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); - PrepareUpdate2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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::LabelStudio.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); + PrepareUpdate2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessUpdate2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/projects/{id}/metricparam/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/projects/{id}/metricparam/\"", + 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); - ProcessUpdate2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/projects/{id}/metricparam/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.MetricParam.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.MetricParam.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessUpdate2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/projects/{id}/metricparam/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/projects/{id}/metricparam/\"", + 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); + ProcessUpdate2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.MetricParam.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.MetricParam.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 project metrics configuration
@@ -235,12 +418,14 @@ partial void ProcessUpdate2ResponseContent( /// /// Agreement metric /// + /// 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 Update2Async( int id, object? additionalParams = default, string? metricName = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.MetricParamUpdateRequest @@ -252,6 +437,7 @@ partial void ProcessUpdate2ResponseContent( return await Update2Async( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.UpdateGcpFunction.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.UpdateGcpFunction.g.cs index 882137d..ca8ddb4 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.UpdateGcpFunction.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.UpdateGcpFunction.g.cs @@ -14,6 +14,7 @@ public partial class ProjectsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -49,12 +50,14 @@ partial void ProcessUpdateGcpFunctionResponse( ///
/// /// + /// 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 UpdateGcpFunctionAsync( int id, global::LabelStudio.GCPCustomFunctionUpdateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -72,22 +75,43 @@ partial void ProcessUpdateGcpFunctionResponse( securityRequirements: s_UpdateGcpFunctionSecurityRequirements, operationName: "UpdateGcpFunctionAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{id}/gcp-custom-function", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{id}/gcp-custom-function", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -97,136 +121,295 @@ partial void ProcessUpdateGcpFunctionResponse( __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::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareUpdateGcpFunctionRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - request: request); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareUpdateGcpFunctionRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + 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); - ProcessUpdateGcpFunctionResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // - if ((int)__response.StatusCode == 500) + 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; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateGcpFunction", + methodName: "UpdateGcpFunctionAsync", + pathTemplate: "$\"/api/projects/{id}/gcp-custom-function\"", + 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) { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateGcpFunction", + methodName: "UpdateGcpFunctionAsync", + pathTemplate: "$\"/api/projects/{id}/gcp-custom-function\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else + + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateGcpFunction", + methodName: "UpdateGcpFunctionAsync", + pathTemplate: "$\"/api/projects/{id}/gcp-custom-function\"", + 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::LabelStudio.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::LabelStudio.ApiException( - message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_500, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_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); - - try - { - __response.EnsureSuccessStatusCode(); - - } - catch (global::System.Exception __ex) + response: __response); + ProcessUpdateGcpFunctionResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateGcpFunction", + methodName: "UpdateGcpFunctionAsync", + pathTemplate: "$\"/api/projects/{id}/gcp-custom-function\"", + 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 + else { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateGcpFunction", + methodName: "UpdateGcpFunctionAsync", + pathTemplate: "$\"/api/projects/{id}/gcp-custom-function\"", + 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) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + // + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } + + throw new global::LabelStudio.ApiException( + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + statusCode: __response.StatusCode) + { + ResponseBody = __content_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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 GCP custom metric Cloud Function
@@ -248,6 +431,7 @@ partial void ProcessUpdateGcpFunctionResponse( /// /// The GCP region for the Cloud Function. Uses default if not provided. /// + /// 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 UpdateGcpFunctionAsync( @@ -255,6 +439,7 @@ partial void ProcessUpdateGcpFunctionResponse( string code, string? project = default, string? region = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.GCPCustomFunctionUpdateRequest @@ -267,6 +452,7 @@ partial void ProcessUpdateGcpFunctionResponse( await UpdateGcpFunctionAsync( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.UpdateLambda.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.UpdateLambda.g.cs index 48b147f..aa56b73 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.UpdateLambda.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.UpdateLambda.g.cs @@ -14,6 +14,7 @@ public partial class ProjectsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -49,12 +50,14 @@ partial void ProcessUpdateLambdaResponse( ///
/// /// + /// 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 UpdateLambdaAsync( int id, global::LabelStudio.AWSCustomFunctionUpdateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -72,22 +75,43 @@ partial void ProcessUpdateLambdaResponse( securityRequirements: s_UpdateLambdaSecurityRequirements, operationName: "UpdateLambdaAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{id}/aws-custom-function", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{id}/aws-custom-function", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -97,136 +121,295 @@ partial void ProcessUpdateLambdaResponse( __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::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareUpdateLambdaRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - request: request); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareUpdateLambdaRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + 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); - ProcessUpdateLambdaResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // - if ((int)__response.StatusCode == 500) + 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; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateLambda", + methodName: "UpdateLambdaAsync", + pathTemplate: "$\"/api/projects/{id}/aws-custom-function\"", + 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) { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateLambda", + methodName: "UpdateLambdaAsync", + pathTemplate: "$\"/api/projects/{id}/aws-custom-function\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else + + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateLambda", + methodName: "UpdateLambdaAsync", + pathTemplate: "$\"/api/projects/{id}/aws-custom-function\"", + 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::LabelStudio.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::LabelStudio.ApiException( - message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_500, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_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); - - try - { - __response.EnsureSuccessStatusCode(); - - } - catch (global::System.Exception __ex) + response: __response); + ProcessUpdateLambdaResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateLambda", + methodName: "UpdateLambdaAsync", + pathTemplate: "$\"/api/projects/{id}/aws-custom-function\"", + 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 + else { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateLambda", + methodName: "UpdateLambdaAsync", + pathTemplate: "$\"/api/projects/{id}/aws-custom-function\"", + 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) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + // + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } + + throw new global::LabelStudio.ApiException( + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + statusCode: __response.StatusCode) + { + ResponseBody = __content_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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 AWS custom metric Lambda
@@ -248,6 +431,7 @@ partial void ProcessUpdateLambdaResponse( /// /// The AWS IAM role ARN for the Lambda function. Uses default if not provided. /// + /// 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 UpdateLambdaAsync( @@ -255,6 +439,7 @@ partial void ProcessUpdateLambdaResponse( string code, string? region = default, string? role = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.AWSCustomFunctionUpdateRequest @@ -267,6 +452,7 @@ partial void ProcessUpdateLambdaResponse( await UpdateLambdaAsync( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.g.cs index 4e9c0af..9b31526 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.g.cs @@ -30,6 +30,9 @@ public sealed partial class ProjectsClient : global::LabelStudio.IProjectsClient #if DEBUG = true; #endif + + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public ProjectsClient( 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 ProjectsClient. + /// 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 ProjectsClient( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::LabelStudio.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::LabelStudio.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/LabelStudio/Generated/LabelStudio.Prompts2Client.BatchFailedPredictions.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Prompts2Client.BatchFailedPredictions.g.cs index 99cd445..5b6578b 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Prompts2Client.BatchFailedPredictions.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Prompts2Client.BatchFailedPredictions.g.cs @@ -14,6 +14,7 @@ public partial class Prompts2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -54,12 +55,14 @@ partial void ProcessBatchFailedPredictionsResponseContent( ///
/// /// + /// 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 BatchFailedPredictionsAsync( global::LabelStudio.BatchFailedPredictionsRequestRequest request, int? numFailedPredictions = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -77,25 +80,46 @@ partial void ProcessBatchFailedPredictionsResponseContent( securityRequirements: s_BatchFailedPredictionsSecurityRequirements, operationName: "BatchFailedPredictionsAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/model-run/batch-failed-predictions", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("num_failed_predictions", numFailedPredictions?.ToString()) - ; - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/model-run/batch-failed-predictions", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("num_failed_predictions", numFailedPredictions?.ToString()) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,119 +129,278 @@ partial void ProcessBatchFailedPredictionsResponseContent( __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); - PrepareBatchFailedPredictionsRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - numFailedPredictions: numFailedPredictions, - 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::LabelStudio.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); + PrepareBatchFailedPredictionsRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + numFailedPredictions: numFailedPredictions, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessBatchFailedPredictionsResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "BatchFailedPredictions", + methodName: "BatchFailedPredictionsAsync", + pathTemplate: "\"/api/model-run/batch-failed-predictions\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "BatchFailedPredictions", + methodName: "BatchFailedPredictionsAsync", + pathTemplate: "\"/api/model-run/batch-failed-predictions\"", + 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); - ProcessBatchFailedPredictionsResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "BatchFailedPredictions", + methodName: "BatchFailedPredictionsAsync", + pathTemplate: "\"/api/model-run/batch-failed-predictions\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.BatchFailedPredictions.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.BatchFailedPredictions.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessBatchFailedPredictionsResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "BatchFailedPredictions", + methodName: "BatchFailedPredictionsAsync", + pathTemplate: "\"/api/model-run/batch-failed-predictions\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "BatchFailedPredictions", + methodName: "BatchFailedPredictionsAsync", + pathTemplate: "\"/api/model-run/batch-failed-predictions\"", + 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); + ProcessBatchFailedPredictionsResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.BatchFailedPredictions.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.BatchFailedPredictions.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 batch of failed predictions
@@ -233,6 +416,7 @@ partial void ProcessBatchFailedPredictionsResponseContent( /// /// /// + /// 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 BatchFailedPredictionsAsync( @@ -240,6 +424,7 @@ partial void ProcessBatchFailedPredictionsResponseContent( int modelrunId, int? numFailedPredictions = default, string? jobId = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.BatchFailedPredictionsRequestRequest @@ -252,6 +437,7 @@ partial void ProcessBatchFailedPredictionsResponseContent( return await BatchFailedPredictionsAsync( numFailedPredictions: numFailedPredictions, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.Prompts2Client.BatchPredictions.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Prompts2Client.BatchPredictions.g.cs index 83a6745..d5aed47 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Prompts2Client.BatchPredictions.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Prompts2Client.BatchPredictions.g.cs @@ -14,6 +14,7 @@ public partial class Prompts2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -54,12 +55,14 @@ partial void ProcessBatchPredictionsResponseContent( ///
/// /// + /// 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 BatchPredictionsAsync( global::LabelStudio.BatchPredictionsRequestRequest request, int? numPredictions = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -77,25 +80,46 @@ partial void ProcessBatchPredictionsResponseContent( securityRequirements: s_BatchPredictionsSecurityRequirements, operationName: "BatchPredictionsAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/model-run/batch-predictions", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("num_predictions", numPredictions?.ToString()) - ; - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/model-run/batch-predictions", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("num_predictions", numPredictions?.ToString()) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,119 +129,278 @@ partial void ProcessBatchPredictionsResponseContent( __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); - PrepareBatchPredictionsRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - numPredictions: numPredictions, - 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::LabelStudio.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); + PrepareBatchPredictionsRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + numPredictions: numPredictions, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessBatchPredictionsResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "BatchPredictions", + methodName: "BatchPredictionsAsync", + pathTemplate: "\"/api/model-run/batch-predictions\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "BatchPredictions", + methodName: "BatchPredictionsAsync", + pathTemplate: "\"/api/model-run/batch-predictions\"", + 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); - ProcessBatchPredictionsResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "BatchPredictions", + methodName: "BatchPredictionsAsync", + pathTemplate: "\"/api/model-run/batch-predictions\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.BatchPredictions.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.BatchPredictions.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessBatchPredictionsResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "BatchPredictions", + methodName: "BatchPredictionsAsync", + pathTemplate: "\"/api/model-run/batch-predictions\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "BatchPredictions", + methodName: "BatchPredictionsAsync", + pathTemplate: "\"/api/model-run/batch-predictions\"", + 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); + ProcessBatchPredictionsResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.BatchPredictions.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.BatchPredictions.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 batch predictions
@@ -233,6 +416,7 @@ partial void ProcessBatchPredictionsResponseContent( /// /// /// + /// 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 BatchPredictionsAsync( @@ -240,6 +424,7 @@ partial void ProcessBatchPredictionsResponseContent( global::System.Collections.Generic.IList results, int? numPredictions = default, string? jobId = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.BatchPredictionsRequestRequest @@ -252,6 +437,7 @@ partial void ProcessBatchPredictionsResponseContent( return await BatchPredictionsAsync( numPredictions: numPredictions, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.Prompts2Client.CompatibleProjects.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Prompts2Client.CompatibleProjects.g.cs index 91a3b9f..52e93dc 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Prompts2Client.CompatibleProjects.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Prompts2Client.CompatibleProjects.g.cs @@ -14,6 +14,7 @@ public partial class Prompts2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -56,6 +57,7 @@ partial void ProcessCompatibleProjectsResponseContent( /// /// Default Value: TextClassification /// + /// 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 CompatibleProjectsAsync( @@ -63,6 +65,7 @@ partial void ProcessCompatibleProjectsResponseContent( int? page = default, int? pageSize = default, global::LabelStudio.ApiPromptsCompatibleProjectsListProjectType? projectType = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -80,28 +83,49 @@ partial void ProcessCompatibleProjectsResponseContent( securityRequirements: s_CompatibleProjectsSecurityRequirements, operationName: "CompatibleProjectsAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/prompts/compatible-projects", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("ordering", ordering) - .AddOptionalParameter("page", page?.ToString()) - .AddOptionalParameter("page_size", pageSize?.ToString()) - .AddOptionalParameter("project_type", projectType?.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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/prompts/compatible-projects", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("ordering", ordering) + .AddOptionalParameter("page", page?.ToString()) + .AddOptionalParameter("page_size", pageSize?.ToString()) + .AddOptionalParameter("project_type", projectType?.ToValueString()) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -111,115 +135,274 @@ partial void ProcessCompatibleProjectsResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCompatibleProjectsRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - ordering: ordering, - page: page, - pageSize: pageSize, - projectType: projectType); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCompatibleProjectsRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + ordering: ordering, + page: page, + pageSize: pageSize, + projectType: projectType); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCompatibleProjectsResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CompatibleProjects", + methodName: "CompatibleProjectsAsync", + pathTemplate: "\"/api/prompts/compatible-projects\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CompatibleProjects", + methodName: "CompatibleProjectsAsync", + pathTemplate: "\"/api/prompts/compatible-projects\"", + 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); - ProcessCompatibleProjectsResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CompatibleProjects", + methodName: "CompatibleProjectsAsync", + pathTemplate: "\"/api/prompts/compatible-projects\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.PaginatedAllRolesProjectListList.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.PaginatedAllRolesProjectListList.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessCompatibleProjectsResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CompatibleProjects", + methodName: "CompatibleProjectsAsync", + pathTemplate: "\"/api/prompts/compatible-projects\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CompatibleProjects", + methodName: "CompatibleProjectsAsync", + pathTemplate: "\"/api/prompts/compatible-projects\"", + 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); + ProcessCompatibleProjectsResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.PaginatedAllRolesProjectListList.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.PaginatedAllRolesProjectListList.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.Prompts2Client.Create.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Prompts2Client.Create.g.cs index 24d66a4..d1949cb 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Prompts2Client.Create.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Prompts2Client.Create.g.cs @@ -14,6 +14,7 @@ public partial class Prompts2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,11 +52,13 @@ partial void ProcessCreateResponseContent( /// Create a new prompt. /// /// + /// 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 CreateAsync( global::LabelStudio.ModelInterfaceRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -72,22 +75,43 @@ partial void ProcessCreateResponseContent( securityRequirements: s_CreateSecurityRequirements, operationName: "CreateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/prompts/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/prompts/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -97,118 +121,277 @@ partial void ProcessCreateResponseContent( __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::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCreateRequest( - 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); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/prompts/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/prompts/\"", + 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); - ProcessCreateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/prompts/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.ModelInterface.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.ModelInterface.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessCreateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/prompts/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/prompts/\"", + 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); + ProcessCreateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.ModelInterface.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ModelInterface.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 prompt
@@ -236,6 +419,7 @@ partial void ProcessCreateResponseContent( /// /// Model name /// + /// 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 CreateAsync( @@ -247,6 +431,7 @@ partial void ProcessCreateResponseContent( int? organization = default, object? outputClasses = default, global::LabelStudio.SkillNameEnum? skillName = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.ModelInterfaceRequest @@ -263,6 +448,7 @@ partial void ProcessCreateResponseContent( return await CreateAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.Prompts2Client.Delete.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Prompts2Client.Delete.g.cs index 5f3423b..9a398bb 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Prompts2Client.Delete.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Prompts2Client.Delete.g.cs @@ -14,6 +14,7 @@ public partial class Prompts2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -46,10 +47,12 @@ partial void ProcessDeleteResponse( /// Delete a prompt by ID ///
/// + /// 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 DeleteAsync( string id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -64,22 +67,43 @@ partial void ProcessDeleteResponse( securityRequirements: s_DeleteSecurityRequirements, operationName: "DeleteAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/prompts/{id}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/prompts/{id}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -89,96 +113,255 @@ partial void ProcessDeleteResponse( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDeleteRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDeleteRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/prompts/{id}/\"", + 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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/prompts/{id}/\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessDeleteResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/prompts/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessDeleteResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/prompts/{id}/\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/prompts/{id}/\"", + httpMethod: "DELETE", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.Prompts2Client.Get2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Prompts2Client.Get2.g.cs index 72fffb8..aba2eb6 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Prompts2Client.Get2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Prompts2Client.Get2.g.cs @@ -14,6 +14,7 @@ public partial class Prompts2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,10 +52,12 @@ partial void ProcessGet2ResponseContent( /// Retrieve a specific prompt. /// /// + /// 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 Get2Async( string id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -69,22 +72,43 @@ partial void ProcessGet2ResponseContent( securityRequirements: s_Get2SecurityRequirements, operationName: "Get2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/prompts/{id}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/prompts/{id}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,112 +118,271 @@ partial void ProcessGet2ResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGet2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGet2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGet2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "$\"/api/prompts/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "$\"/api/prompts/{id}/\"", + 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); - ProcessGet2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "$\"/api/prompts/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.ModelInterfaceSerializerGET.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.ModelInterfaceSerializerGET.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGet2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "$\"/api/prompts/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "$\"/api/prompts/{id}/\"", + 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); + ProcessGet2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.ModelInterfaceSerializerGET.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ModelInterfaceSerializerGET.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.Prompts2Client.List2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Prompts2Client.List2.g.cs index 373ec0c..b43a5cd 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Prompts2Client.List2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Prompts2Client.List2.g.cs @@ -14,6 +14,7 @@ public partial class Prompts2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,10 +46,12 @@ partial void ProcessList2ResponseContent( /// List all prompts. /// /// + /// 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> List2Async( string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -63,25 +66,46 @@ partial void ProcessList2ResponseContent( securityRequirements: s_List2SecurityRequirements, operationName: "List2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/prompts/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("ordering", ordering) - ; - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/prompts/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("ordering", ordering) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -91,112 +115,271 @@ partial void ProcessList2ResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareList2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - ordering: ordering); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareList2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + ordering: ordering); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessList2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/prompts/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/prompts/\"", + 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); - ProcessList2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/prompts/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessList2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/prompts/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/prompts/\"", + 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); + ProcessList2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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 + (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.Prompts2Client.SubsetTasks.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Prompts2Client.SubsetTasks.g.cs index 079cb84..87f10d9 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Prompts2Client.SubsetTasks.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Prompts2Client.SubsetTasks.g.cs @@ -14,6 +14,7 @@ public partial class Prompts2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -73,6 +74,7 @@ partial void ProcessSubsetTasksResponseContent( /// /// /// + /// 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 SubsetTasksAsync( @@ -84,6 +86,7 @@ partial void ProcessSubsetTasksResponseContent( int? pageSize = default, int? parentModel = default, string? projectSubset = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -105,31 +108,52 @@ partial void ProcessSubsetTasksResponseContent( securityRequirements: s_SubsetTasksSecurityRequirements, operationName: "SubsetTasksAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{projectPk}/subset-tasks", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("include_total", includeTotal?.ToString().ToLowerInvariant()) - .AddOptionalParameter("model_run", modelRun?.ToString()) - .AddOptionalParameter("ordering", ordering) - .AddOptionalParameter("page", page?.ToString()) - .AddOptionalParameter("page_size", pageSize?.ToString()) - .AddOptionalParameter("parent_model", parentModel?.ToString()) - .AddOptionalParameter("project_subset", projectSubset) - ; - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{projectPk}/subset-tasks", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("include_total", includeTotal?.ToString().ToLowerInvariant()) + .AddOptionalParameter("model_run", modelRun?.ToString()) + .AddOptionalParameter("ordering", ordering) + .AddOptionalParameter("page", page?.ToString()) + .AddOptionalParameter("page_size", pageSize?.ToString()) + .AddOptionalParameter("parent_model", parentModel?.ToString()) + .AddOptionalParameter("project_subset", projectSubset) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -139,152 +163,311 @@ partial void ProcessSubsetTasksResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareSubsetTasksRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - includeTotal: includeTotal, - modelRun: modelRun, - ordering: ordering, - page: page, - pageSize: pageSize, - parentModel: parentModel, - projectPk: projectPk, - projectSubset: projectSubset); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareSubsetTasksRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + includeTotal: includeTotal, + modelRun: modelRun, + ordering: ordering, + page: page, + pageSize: pageSize, + parentModel: parentModel, + projectPk: projectPk, + projectSubset: projectSubset); - 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); - ProcessSubsetTasksResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // - if ((int)__response.StatusCode == 400) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_400 = null; - global::System.Exception? __exception_400 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "SubsetTasks", + methodName: "SubsetTasksAsync", + pathTemplate: "$\"/api/projects/{projectPk}/subset-tasks\"", + 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) { - __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "SubsetTasks", + methodName: "SubsetTasksAsync", + pathTemplate: "$\"/api/projects/{projectPk}/subset-tasks\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else + + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "SubsetTasks", + methodName: "SubsetTasksAsync", + pathTemplate: "$\"/api/projects/{projectPk}/subset-tasks\"", + 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::LabelStudio.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::LabelStudio.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 (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); - ProcessSubsetTasksResponseContent( + response: __response); + ProcessSubsetTasksResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::LabelStudio.PaginatedProjectSubsetTasksResponseList.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "SubsetTasks", + methodName: "SubsetTasksAsync", + pathTemplate: "$\"/api/projects/{projectPk}/subset-tasks\"", + 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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "SubsetTasks", + methodName: "SubsetTasksAsync", + pathTemplate: "$\"/api/projects/{projectPk}/subset-tasks\"", + 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); + // + 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; + } - return - await global::LabelStudio.PaginatedProjectSubsetTasksResponseList.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) - { - } + throw new global::LabelStudio.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 (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessSubsetTasksResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.PaginatedProjectSubsetTasksResponseList.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.PaginatedProjectSubsetTasksResponseList.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.Prompts2Client.Subsets.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Prompts2Client.Subsets.g.cs index 0ab6cde..059c4b1 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Prompts2Client.Subsets.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Prompts2Client.Subsets.g.cs @@ -14,6 +14,7 @@ public partial class Prompts2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -55,11 +56,13 @@ partial void ProcessSubsetsResponseContent( /// /// /// + /// 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> SubsetsAsync( int projectPk, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -75,25 +78,46 @@ partial void ProcessSubsetsResponseContent( securityRequirements: s_SubsetsSecurityRequirements, operationName: "SubsetsAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{projectPk}/subsets", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("ordering", ordering) - ; - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{projectPk}/subsets", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("ordering", ordering) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -103,113 +127,272 @@ partial void ProcessSubsetsResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareSubsetsRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - ordering: ordering, - projectPk: projectPk); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareSubsetsRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + ordering: ordering, + projectPk: projectPk); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessSubsetsResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Subsets", + methodName: "SubsetsAsync", + pathTemplate: "$\"/api/projects/{projectPk}/subsets\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Subsets", + methodName: "SubsetsAsync", + pathTemplate: "$\"/api/projects/{projectPk}/subsets\"", + 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); - ProcessSubsetsResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Subsets", + methodName: "SubsetsAsync", + pathTemplate: "$\"/api/projects/{projectPk}/subsets\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessSubsetsResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Subsets", + methodName: "SubsetsAsync", + pathTemplate: "$\"/api/projects/{projectPk}/subsets\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Subsets", + methodName: "SubsetsAsync", + pathTemplate: "$\"/api/projects/{projectPk}/subsets\"", + 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); + ProcessSubsetsResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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 + (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.Prompts2Client.Update.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Prompts2Client.Update.g.cs index 88b0aae..531a6d9 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Prompts2Client.Update.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Prompts2Client.Update.g.cs @@ -14,6 +14,7 @@ public partial class Prompts2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -54,12 +55,14 @@ partial void ProcessUpdateResponseContent( /// /// /// + /// 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 UpdateAsync( string id, global::LabelStudio.PatchedModelInterfaceRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -77,22 +80,43 @@ partial void ProcessUpdateResponseContent( securityRequirements: s_UpdateSecurityRequirements, operationName: "UpdateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/prompts/{id}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/prompts/{id}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -102,119 +126,278 @@ partial void ProcessUpdateResponseContent( __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); - PrepareUpdateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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::LabelStudio.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); + PrepareUpdateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessUpdateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/prompts/{id}/\"", + 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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/prompts/{id}/\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessUpdateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/prompts/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.ModelInterface.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.ModelInterface.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessUpdateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/prompts/{id}/\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/prompts/{id}/\"", + httpMethod: "PATCH", + 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); + ProcessUpdateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.ModelInterface.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ModelInterface.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 prompt
@@ -243,6 +426,7 @@ partial void ProcessUpdateResponseContent( /// /// Model name /// + /// 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 UpdateAsync( @@ -255,6 +439,7 @@ partial void ProcessUpdateResponseContent( object? outputClasses = default, global::LabelStudio.SkillNameEnum? skillName = default, string? title = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.PatchedModelInterfaceRequest @@ -272,6 +457,7 @@ partial void ProcessUpdateResponseContent( return await UpdateAsync( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.Prompts2Client.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Prompts2Client.g.cs index c69073a..3f7511d 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Prompts2Client.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Prompts2Client.g.cs @@ -30,6 +30,9 @@ public sealed partial class Prompts2Client : global::LabelStudio.IPrompts2Client #if DEBUG = true; #endif + + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public Prompts2Client( 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 Prompts2Client. + /// 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 Prompts2Client( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::LabelStudio.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::LabelStudio.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/LabelStudio/Generated/LabelStudio.PromptsClient.ApiPromptsUpdate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.PromptsClient.ApiPromptsUpdate.g.cs index 140dd59..74c58ee 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.PromptsClient.ApiPromptsUpdate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.PromptsClient.ApiPromptsUpdate.g.cs @@ -14,6 +14,7 @@ public partial class PromptsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -54,12 +55,14 @@ partial void ProcessApiPromptsUpdateResponseContent( ///
/// /// + /// 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 ApiPromptsUpdateAsync( string id, global::LabelStudio.ModelInterfaceRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -77,22 +80,43 @@ partial void ProcessApiPromptsUpdateResponseContent( securityRequirements: s_ApiPromptsUpdateSecurityRequirements, operationName: "ApiPromptsUpdateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/prompts/{id}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/prompts/{id}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -102,119 +126,278 @@ partial void ProcessApiPromptsUpdateResponseContent( __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); - PrepareApiPromptsUpdateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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::LabelStudio.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); + PrepareApiPromptsUpdateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiPromptsUpdateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiPromptsUpdate", + methodName: "ApiPromptsUpdateAsync", + pathTemplate: "$\"/api/prompts/{id}/\"", + 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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiPromptsUpdate", + methodName: "ApiPromptsUpdateAsync", + pathTemplate: "$\"/api/prompts/{id}/\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessApiPromptsUpdateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiPromptsUpdate", + methodName: "ApiPromptsUpdateAsync", + pathTemplate: "$\"/api/prompts/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.ModelInterface.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.ModelInterface.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessApiPromptsUpdateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiPromptsUpdate", + methodName: "ApiPromptsUpdateAsync", + pathTemplate: "$\"/api/prompts/{id}/\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiPromptsUpdate", + methodName: "ApiPromptsUpdateAsync", + pathTemplate: "$\"/api/prompts/{id}/\"", + httpMethod: "PUT", + 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); + ProcessApiPromptsUpdateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.ModelInterface.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ModelInterface.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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(); + } } /// /// ✨ Put prompt
@@ -243,6 +426,7 @@ partial void ProcessApiPromptsUpdateResponseContent( /// /// Model name /// + /// 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 ApiPromptsUpdateAsync( @@ -255,6 +439,7 @@ partial void ProcessApiPromptsUpdateResponseContent( int? organization = default, object? outputClasses = default, global::LabelStudio.SkillNameEnum? skillName = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.ModelInterfaceRequest @@ -272,6 +457,7 @@ partial void ProcessApiPromptsUpdateResponseContent( return await ApiPromptsUpdateAsync( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.PromptsClient.ApiPromptsVersionsUpdate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.PromptsClient.ApiPromptsVersionsUpdate.g.cs index f5c54c9..435e867 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.PromptsClient.ApiPromptsVersionsUpdate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.PromptsClient.ApiPromptsVersionsUpdate.g.cs @@ -14,6 +14,7 @@ public partial class PromptsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -57,6 +58,7 @@ partial void ProcessApiPromptsVersionsUpdateResponseContent( /// /// /// + /// 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 ApiPromptsVersionsUpdateAsync( @@ -64,6 +66,7 @@ partial void ProcessApiPromptsVersionsUpdateResponseContent( int versionId, global::LabelStudio.ThirdPartyModelVersionRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -82,22 +85,43 @@ partial void ProcessApiPromptsVersionsUpdateResponseContent( securityRequirements: s_ApiPromptsVersionsUpdateSecurityRequirements, operationName: "ApiPromptsVersionsUpdateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/prompts/{promptId}/versions/{versionId}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/prompts/{promptId}/versions/{versionId}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -107,120 +131,279 @@ partial void ProcessApiPromptsVersionsUpdateResponseContent( __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); - PrepareApiPromptsVersionsUpdateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - promptId: promptId, - versionId: versionId, - 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::LabelStudio.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); + PrepareApiPromptsVersionsUpdateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + promptId: promptId, + versionId: versionId, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiPromptsVersionsUpdateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiPromptsVersionsUpdate", + methodName: "ApiPromptsVersionsUpdateAsync", + pathTemplate: "$\"/api/prompts/{promptId}/versions/{versionId}\"", + 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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiPromptsVersionsUpdate", + methodName: "ApiPromptsVersionsUpdateAsync", + pathTemplate: "$\"/api/prompts/{promptId}/versions/{versionId}\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessApiPromptsVersionsUpdateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiPromptsVersionsUpdate", + methodName: "ApiPromptsVersionsUpdateAsync", + pathTemplate: "$\"/api/prompts/{promptId}/versions/{versionId}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.ThirdPartyModelVersion.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.ThirdPartyModelVersion.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessApiPromptsVersionsUpdateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiPromptsVersionsUpdate", + methodName: "ApiPromptsVersionsUpdateAsync", + pathTemplate: "$\"/api/prompts/{promptId}/versions/{versionId}\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiPromptsVersionsUpdate", + methodName: "ApiPromptsVersionsUpdateAsync", + pathTemplate: "$\"/api/prompts/{promptId}/versions/{versionId}\"", + httpMethod: "PUT", + 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); + ProcessApiPromptsVersionsUpdateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.ThirdPartyModelVersion.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ThirdPartyModelVersion.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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(); + } } /// /// ✨ Put prompt version
@@ -258,6 +441,7 @@ partial void ProcessApiPromptsVersionsUpdateResponseContent( /// /// Model name /// + /// 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 ApiPromptsVersionsUpdateAsync( @@ -270,6 +454,7 @@ partial void ProcessApiPromptsVersionsUpdateResponseContent( int? organization = default, int? parentModel = default, global::LabelStudio.ProviderEnum? provider = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.ThirdPartyModelVersionRequest @@ -287,6 +472,7 @@ partial void ProcessApiPromptsVersionsUpdateResponseContent( promptId: promptId, versionId: versionId, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.PromptsClient.Cancel.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.PromptsClient.Cancel.g.cs index ac35829..6b4e2bc 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.PromptsClient.Cancel.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.PromptsClient.Cancel.g.cs @@ -14,6 +14,7 @@ public partial class PromptsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -57,12 +58,14 @@ partial void ProcessCancelResponseContent( /// /// /// + /// 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 CancelAsync( int inferenceRunId, int promptId, int versionId, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -79,22 +82,43 @@ partial void ProcessCancelResponseContent( securityRequirements: s_CancelSecurityRequirements, operationName: "CancelAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/prompts/{promptId}/versions/{versionId}/inference-runs/{inferenceRunId}/cancel", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/prompts/{promptId}/versions/{versionId}/inference-runs/{inferenceRunId}/cancel", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -104,114 +128,273 @@ partial void ProcessCancelResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCancelRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - inferenceRunId: inferenceRunId, - promptId: promptId, - versionId: versionId); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCancelRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + inferenceRunId: inferenceRunId, + promptId: promptId, + versionId: versionId); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCancelResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Cancel", + methodName: "CancelAsync", + pathTemplate: "$\"/api/prompts/{promptId}/versions/{versionId}/inference-runs/{inferenceRunId}/cancel\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Cancel", + methodName: "CancelAsync", + pathTemplate: "$\"/api/prompts/{promptId}/versions/{versionId}/inference-runs/{inferenceRunId}/cancel\"", + 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); - ProcessCancelResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Cancel", + methodName: "CancelAsync", + pathTemplate: "$\"/api/prompts/{promptId}/versions/{versionId}/inference-runs/{inferenceRunId}/cancel\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.CancelModelRunResponse.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.CancelModelRunResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessCancelResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Cancel", + methodName: "CancelAsync", + pathTemplate: "$\"/api/prompts/{promptId}/versions/{versionId}/inference-runs/{inferenceRunId}/cancel\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Cancel", + methodName: "CancelAsync", + pathTemplate: "$\"/api/prompts/{promptId}/versions/{versionId}/inference-runs/{inferenceRunId}/cancel\"", + 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); + ProcessCancelResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.CancelModelRunResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.CancelModelRunResponse.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.PromptsClient.CostEstimate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.PromptsClient.CostEstimate.g.cs index dcad202..ac31026 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.PromptsClient.CostEstimate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.PromptsClient.CostEstimate.g.cs @@ -14,6 +14,7 @@ public partial class PromptsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -54,11 +55,13 @@ partial void ProcessCostEstimateResponseContent( ///
/// /// + /// 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 CostEstimateAsync( int promptId, int versionId, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -74,22 +77,43 @@ partial void ProcessCostEstimateResponseContent( securityRequirements: s_CostEstimateSecurityRequirements, operationName: "CostEstimateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/prompts/{promptId}/versions/{versionId}/cost-estimate", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/prompts/{promptId}/versions/{versionId}/cost-estimate", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -99,113 +123,272 @@ partial void ProcessCostEstimateResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCostEstimateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - promptId: promptId, - versionId: versionId); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCostEstimateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + promptId: promptId, + versionId: versionId); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCostEstimateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CostEstimate", + methodName: "CostEstimateAsync", + pathTemplate: "$\"/api/prompts/{promptId}/versions/{versionId}/cost-estimate\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CostEstimate", + methodName: "CostEstimateAsync", + pathTemplate: "$\"/api/prompts/{promptId}/versions/{versionId}/cost-estimate\"", + 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); - ProcessCostEstimateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CostEstimate", + methodName: "CostEstimateAsync", + pathTemplate: "$\"/api/prompts/{promptId}/versions/{versionId}/cost-estimate\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.InferenceRunCostEstimate.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.InferenceRunCostEstimate.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessCostEstimateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CostEstimate", + methodName: "CostEstimateAsync", + pathTemplate: "$\"/api/prompts/{promptId}/versions/{versionId}/cost-estimate\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CostEstimate", + methodName: "CostEstimateAsync", + pathTemplate: "$\"/api/prompts/{promptId}/versions/{versionId}/cost-estimate\"", + 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); + ProcessCostEstimateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.InferenceRunCostEstimate.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.InferenceRunCostEstimate.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.PromptsClient.Create2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.PromptsClient.Create2.g.cs index 395616b..760c0a4 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.PromptsClient.Create2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.PromptsClient.Create2.g.cs @@ -14,6 +14,7 @@ public partial class PromptsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -54,12 +55,14 @@ partial void ProcessCreate2ResponseContent( ///
/// /// + /// 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 Create2Async( int promptId, global::LabelStudio.ThirdPartyModelVersionRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -77,22 +80,43 @@ partial void ProcessCreate2ResponseContent( securityRequirements: s_Create2SecurityRequirements, operationName: "Create2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/prompts/{promptId}/versions", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/prompts/{promptId}/versions", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -102,119 +126,278 @@ partial void ProcessCreate2ResponseContent( __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); - PrepareCreate2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - promptId: promptId, - 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::LabelStudio.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); + PrepareCreate2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + promptId: promptId, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreate2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "$\"/api/prompts/{promptId}/versions\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "$\"/api/prompts/{promptId}/versions\"", + 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); - ProcessCreate2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "$\"/api/prompts/{promptId}/versions\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.ThirdPartyModelVersion.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.ThirdPartyModelVersion.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessCreate2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "$\"/api/prompts/{promptId}/versions\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "$\"/api/prompts/{promptId}/versions\"", + 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); + ProcessCreate2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.ThirdPartyModelVersion.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ThirdPartyModelVersion.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 prompt version
@@ -251,6 +434,7 @@ partial void ProcessCreate2ResponseContent( /// /// Model name /// + /// 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 Create2Async( @@ -262,6 +446,7 @@ partial void ProcessCreate2ResponseContent( int? organization = default, int? parentModel = default, global::LabelStudio.ProviderEnum? provider = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.ThirdPartyModelVersionRequest @@ -278,6 +463,7 @@ partial void ProcessCreate2ResponseContent( return await Create2Async( promptId: promptId, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.PromptsClient.Create3.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.PromptsClient.Create3.g.cs index b2fa665..8cefe52 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.PromptsClient.Create3.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.PromptsClient.Create3.g.cs @@ -14,6 +14,7 @@ public partial class PromptsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -57,6 +58,7 @@ partial void ProcessCreate3ResponseContent( /// /// /// + /// 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 Create3Async( @@ -64,6 +66,7 @@ partial void ProcessCreate3ResponseContent( int versionId, global::LabelStudio.ModelRunRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -82,22 +85,43 @@ partial void ProcessCreate3ResponseContent( securityRequirements: s_Create3SecurityRequirements, operationName: "Create3Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/prompts/{promptId}/versions/{versionId}/inference-runs", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/prompts/{promptId}/versions/{versionId}/inference-runs", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -107,120 +131,279 @@ partial void ProcessCreate3ResponseContent( __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); - PrepareCreate3Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - promptId: promptId, - versionId: versionId, - 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::LabelStudio.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); + PrepareCreate3Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + promptId: promptId, + versionId: versionId, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreate3Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create3", + methodName: "Create3Async", + pathTemplate: "$\"/api/prompts/{promptId}/versions/{versionId}/inference-runs\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create3", + methodName: "Create3Async", + pathTemplate: "$\"/api/prompts/{promptId}/versions/{versionId}/inference-runs\"", + 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); - ProcessCreate3ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create3", + methodName: "Create3Async", + pathTemplate: "$\"/api/prompts/{promptId}/versions/{versionId}/inference-runs\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.ModelRun.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.ModelRun.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessCreate3Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create3", + methodName: "Create3Async", + pathTemplate: "$\"/api/prompts/{promptId}/versions/{versionId}/inference-runs\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create3", + methodName: "Create3Async", + pathTemplate: "$\"/api/prompts/{promptId}/versions/{versionId}/inference-runs\"", + 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); + ProcessCreate3ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.ModelRun.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ModelRun.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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(); + } } /// /// ✨ Run prompt inference
@@ -253,6 +436,7 @@ partial void ProcessCreate3ResponseContent( /// /// /// + /// 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 Create3Async( @@ -267,6 +451,7 @@ partial void ProcessCreate3ResponseContent( int? totalCorrectPredictions = default, int? totalPredictions = default, int? totalTasks = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.ModelRunRequest @@ -286,6 +471,7 @@ partial void ProcessCreate3ResponseContent( promptId: promptId, versionId: versionId, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.PromptsClient.Delete2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.PromptsClient.Delete2.g.cs index beec867..a0dbe67 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.PromptsClient.Delete2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.PromptsClient.Delete2.g.cs @@ -14,6 +14,7 @@ public partial class PromptsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -49,11 +50,13 @@ partial void ProcessDelete2Response( ///
/// /// + /// 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 Delete2Async( int promptId, int versionId, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -69,22 +72,43 @@ partial void ProcessDelete2Response( securityRequirements: s_Delete2SecurityRequirements, operationName: "Delete2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/prompts/{promptId}/versions/{versionId}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/prompts/{promptId}/versions/{versionId}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,97 +118,256 @@ partial void ProcessDelete2Response( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDelete2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - promptId: promptId, - versionId: versionId); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDelete2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + promptId: promptId, + versionId: versionId); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/prompts/{promptId}/versions/{versionId}\"", + 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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/prompts/{promptId}/versions/{versionId}\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessDelete2Response( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/prompts/{promptId}/versions/{versionId}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessDelete2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/prompts/{promptId}/versions/{versionId}\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/prompts/{promptId}/versions/{versionId}\"", + httpMethod: "DELETE", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.PromptsClient.Get.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.PromptsClient.Get.g.cs index 5f3b09e..d4d8c7d 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.PromptsClient.Get.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.PromptsClient.Get.g.cs @@ -14,6 +14,7 @@ public partial class PromptsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -54,11 +55,13 @@ partial void ProcessGetResponseContent( ///
/// /// + /// 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 GetAsync( int id, string indicatorKey, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -74,22 +77,43 @@ partial void ProcessGetResponseContent( securityRequirements: s_GetSecurityRequirements, operationName: "GetAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/inference-runs/{id}/indicators/{indicatorKey}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/inference-runs/{id}/indicators/{indicatorKey}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -99,113 +123,272 @@ partial void ProcessGetResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - indicatorKey: indicatorKey); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + indicatorKey: indicatorKey); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/inference-runs/{id}/indicators/{indicatorKey}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/inference-runs/{id}/indicators/{indicatorKey}\"", + 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); - ProcessGetResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/inference-runs/{id}/indicators/{indicatorKey}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.LSEKeyIndicatorValue.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.LSEKeyIndicatorValue.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGetResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/inference-runs/{id}/indicators/{indicatorKey}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/inference-runs/{id}/indicators/{indicatorKey}\"", + 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); + ProcessGetResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.LSEKeyIndicatorValue.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.LSEKeyIndicatorValue.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.PromptsClient.Get3.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.PromptsClient.Get3.g.cs index 5d29843..427d375 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.PromptsClient.Get3.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.PromptsClient.Get3.g.cs @@ -14,6 +14,7 @@ public partial class PromptsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -54,11 +55,13 @@ partial void ProcessGet3ResponseContent( /// /// /// + /// 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 Get3Async( int promptId, int versionId, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -74,22 +77,43 @@ partial void ProcessGet3ResponseContent( securityRequirements: s_Get3SecurityRequirements, operationName: "Get3Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/prompts/{promptId}/versions/{versionId}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/prompts/{promptId}/versions/{versionId}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -99,113 +123,272 @@ partial void ProcessGet3ResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGet3Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - promptId: promptId, - versionId: versionId); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGet3Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + promptId: promptId, + versionId: versionId); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGet3Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get3", + methodName: "Get3Async", + pathTemplate: "$\"/api/prompts/{promptId}/versions/{versionId}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get3", + methodName: "Get3Async", + pathTemplate: "$\"/api/prompts/{promptId}/versions/{versionId}\"", + 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); - ProcessGet3ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get3", + methodName: "Get3Async", + pathTemplate: "$\"/api/prompts/{promptId}/versions/{versionId}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.ThirdPartyModelVersion.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.ThirdPartyModelVersion.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGet3Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get3", + methodName: "Get3Async", + pathTemplate: "$\"/api/prompts/{promptId}/versions/{versionId}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get3", + methodName: "Get3Async", + pathTemplate: "$\"/api/prompts/{promptId}/versions/{versionId}\"", + 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); + ProcessGet3ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.ThirdPartyModelVersion.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ThirdPartyModelVersion.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.PromptsClient.GetDefaultVersionName.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.PromptsClient.GetDefaultVersionName.g.cs index b58f1ee..ea458e5 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.PromptsClient.GetDefaultVersionName.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.PromptsClient.GetDefaultVersionName.g.cs @@ -14,6 +14,7 @@ public partial class PromptsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -46,10 +47,12 @@ partial void ProcessGetDefaultVersionNameResponse( /// Get default prompt version name /// /// + /// 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 GetDefaultVersionNameAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -64,22 +67,43 @@ partial void ProcessGetDefaultVersionNameResponse( securityRequirements: s_GetDefaultVersionNameSecurityRequirements, operationName: "GetDefaultVersionNameAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/prompts/{id}/get-default-version-name", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/prompts/{id}/get-default-version-name", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,96 +113,255 @@ partial void ProcessGetDefaultVersionNameResponse( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetDefaultVersionNameRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetDefaultVersionNameRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetDefaultVersionName", + methodName: "GetDefaultVersionNameAsync", + pathTemplate: "$\"/api/prompts/{id}/get-default-version-name\"", + 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: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetDefaultVersionName", + methodName: "GetDefaultVersionNameAsync", + pathTemplate: "$\"/api/prompts/{id}/get-default-version-name\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetDefaultVersionNameResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetDefaultVersionName", + methodName: "GetDefaultVersionNameAsync", + pathTemplate: "$\"/api/prompts/{id}/get-default-version-name\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGetDefaultVersionNameResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetDefaultVersionName", + methodName: "GetDefaultVersionNameAsync", + pathTemplate: "$\"/api/prompts/{id}/get-default-version-name\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetDefaultVersionName", + methodName: "GetDefaultVersionNameAsync", + pathTemplate: "$\"/api/prompts/{id}/get-default-version-name\"", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.PromptsClient.GetRefinedPrompt.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.PromptsClient.GetRefinedPrompt.g.cs index 93dccae..c188d02 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.PromptsClient.GetRefinedPrompt.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.PromptsClient.GetRefinedPrompt.g.cs @@ -14,6 +14,7 @@ public partial class PromptsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -57,12 +58,14 @@ partial void ProcessGetRefinedPromptResponseContent( /// /// /// + /// 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 GetRefinedPromptAsync( int promptId, int versionId, string? refinementJobId = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -79,25 +82,46 @@ partial void ProcessGetRefinedPromptResponseContent( securityRequirements: s_GetRefinedPromptSecurityRequirements, operationName: "GetRefinedPromptAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/prompts/{promptId}/versions/{versionId}/refine", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("refinement_job_id", refinementJobId) - ; - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/prompts/{promptId}/versions/{versionId}/refine", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("refinement_job_id", refinementJobId) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,114 +131,273 @@ partial void ProcessGetRefinedPromptResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetRefinedPromptRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - promptId: promptId, - refinementJobId: refinementJobId, - versionId: versionId); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetRefinedPromptRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + promptId: promptId, + refinementJobId: refinementJobId, + versionId: versionId); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetRefinedPromptResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetRefinedPrompt", + methodName: "GetRefinedPromptAsync", + pathTemplate: "$\"/api/prompts/{promptId}/versions/{versionId}/refine\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetRefinedPrompt", + methodName: "GetRefinedPromptAsync", + pathTemplate: "$\"/api/prompts/{promptId}/versions/{versionId}/refine\"", + 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); - ProcessGetRefinedPromptResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetRefinedPrompt", + methodName: "GetRefinedPromptAsync", + pathTemplate: "$\"/api/prompts/{promptId}/versions/{versionId}/refine\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.RefinedPromptResponse.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.RefinedPromptResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGetRefinedPromptResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetRefinedPrompt", + methodName: "GetRefinedPromptAsync", + pathTemplate: "$\"/api/prompts/{promptId}/versions/{versionId}/refine\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetRefinedPrompt", + methodName: "GetRefinedPromptAsync", + pathTemplate: "$\"/api/prompts/{promptId}/versions/{versionId}/refine\"", + 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); + ProcessGetRefinedPromptResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.RefinedPromptResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.RefinedPromptResponse.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.PromptsClient.List.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.PromptsClient.List.g.cs index d5fde15..de57f71 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.PromptsClient.List.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.PromptsClient.List.g.cs @@ -14,6 +14,7 @@ public partial class PromptsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,10 +52,12 @@ partial void ProcessListResponseContent( /// Get key indicators for the Prompt dashboard. /// /// + /// 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> ListAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -69,22 +72,43 @@ partial void ProcessListResponseContent( securityRequirements: s_ListSecurityRequirements, operationName: "ListAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/inference-runs/{id}/indicators/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/inference-runs/{id}/indicators/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,112 +118,271 @@ partial void ProcessListResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareListRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareListRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessListResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "$\"/api/inference-runs/{id}/indicators/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "$\"/api/inference-runs/{id}/indicators/\"", + 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); - ProcessListResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "$\"/api/inference-runs/{id}/indicators/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessListResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "$\"/api/inference-runs/{id}/indicators/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "$\"/api/inference-runs/{id}/indicators/\"", + 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); + ProcessListResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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 + (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.PromptsClient.List3.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.PromptsClient.List3.g.cs index 2c065be..d23a5bf 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.PromptsClient.List3.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.PromptsClient.List3.g.cs @@ -14,6 +14,7 @@ public partial class PromptsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -54,11 +55,13 @@ partial void ProcessList3ResponseContent( /// /// /// + /// 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> List3Async( int promptId, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -74,25 +77,46 @@ partial void ProcessList3ResponseContent( securityRequirements: s_List3SecurityRequirements, operationName: "List3Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/prompts/{promptId}/versions", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("ordering", ordering) - ; - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/prompts/{promptId}/versions", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("ordering", ordering) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,113 +126,272 @@ partial void ProcessList3ResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareList3Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - ordering: ordering, - promptId: promptId); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareList3Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + ordering: ordering, + promptId: promptId); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessList3Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List3", + methodName: "List3Async", + pathTemplate: "$\"/api/prompts/{promptId}/versions\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List3", + methodName: "List3Async", + pathTemplate: "$\"/api/prompts/{promptId}/versions\"", + 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); - ProcessList3ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List3", + methodName: "List3Async", + pathTemplate: "$\"/api/prompts/{promptId}/versions\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessList3Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List3", + methodName: "List3Async", + pathTemplate: "$\"/api/prompts/{promptId}/versions\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List3", + methodName: "List3Async", + pathTemplate: "$\"/api/prompts/{promptId}/versions\"", + 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); + ProcessList3ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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 + (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.PromptsClient.List4.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.PromptsClient.List4.g.cs index 8432728..4c28e99 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.PromptsClient.List4.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.PromptsClient.List4.g.cs @@ -14,6 +14,7 @@ public partial class PromptsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -66,6 +67,7 @@ partial void ProcessList4ResponseContent( /// /// /// + /// 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> List4Async( @@ -75,6 +77,7 @@ partial void ProcessList4ResponseContent( int? parentModel = default, int? project = default, global::LabelStudio.ApiPromptsVersionsInferenceRunsListProjectSubset? projectSubset = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -94,28 +97,49 @@ partial void ProcessList4ResponseContent( securityRequirements: s_List4SecurityRequirements, operationName: "List4Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/prompts/{promptId}/versions/{versionId}/inference-runs", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("ordering", ordering) - .AddOptionalParameter("parent_model", parentModel?.ToString()) - .AddOptionalParameter("project", project?.ToString()) - .AddOptionalParameter("project_subset", projectSubset?.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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/prompts/{promptId}/versions/{versionId}/inference-runs", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("ordering", ordering) + .AddOptionalParameter("parent_model", parentModel?.ToString()) + .AddOptionalParameter("project", project?.ToString()) + .AddOptionalParameter("project_subset", projectSubset?.ToValueString()) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,117 +149,276 @@ partial void ProcessList4ResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareList4Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - ordering: ordering, - parentModel: parentModel, - project: project, - projectSubset: projectSubset, - promptId: promptId, - versionId: versionId); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareList4Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + ordering: ordering, + parentModel: parentModel, + project: project, + projectSubset: projectSubset, + promptId: promptId, + versionId: versionId); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessList4Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List4", + methodName: "List4Async", + pathTemplate: "$\"/api/prompts/{promptId}/versions/{versionId}/inference-runs\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List4", + methodName: "List4Async", + pathTemplate: "$\"/api/prompts/{promptId}/versions/{versionId}/inference-runs\"", + 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); - ProcessList4ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List4", + methodName: "List4Async", + pathTemplate: "$\"/api/prompts/{promptId}/versions/{versionId}/inference-runs\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessList4Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List4", + methodName: "List4Async", + pathTemplate: "$\"/api/prompts/{promptId}/versions/{versionId}/inference-runs\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List4", + methodName: "List4Async", + pathTemplate: "$\"/api/prompts/{promptId}/versions/{versionId}/inference-runs\"", + 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); + ProcessList4ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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 + (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.PromptsClient.RefinePrompt.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.PromptsClient.RefinePrompt.g.cs index 88c7d92..2a95d28 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.PromptsClient.RefinePrompt.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.PromptsClient.RefinePrompt.g.cs @@ -14,6 +14,7 @@ public partial class PromptsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -60,6 +61,7 @@ partial void ProcessRefinePromptResponseContent( /// /// /// + /// 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 RefinePromptAsync( @@ -68,6 +70,7 @@ partial void ProcessRefinePromptResponseContent( global::LabelStudio.RefinePromptRequestRequest request, bool? async = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -87,25 +90,46 @@ partial void ProcessRefinePromptResponseContent( securityRequirements: s_RefinePromptSecurityRequirements, operationName: "RefinePromptAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/prompts/{promptId}/versions/{versionId}/refine", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("async", async?.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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/prompts/{promptId}/versions/{versionId}/refine", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("async", async?.ToString().ToLowerInvariant()) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,121 +139,280 @@ partial void ProcessRefinePromptResponseContent( __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); - PrepareRefinePromptRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - async: async, - promptId: promptId, - versionId: versionId, - 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::LabelStudio.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); + PrepareRefinePromptRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + async: async, + promptId: promptId, + versionId: versionId, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessRefinePromptResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RefinePrompt", + methodName: "RefinePromptAsync", + pathTemplate: "$\"/api/prompts/{promptId}/versions/{versionId}/refine\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RefinePrompt", + methodName: "RefinePromptAsync", + pathTemplate: "$\"/api/prompts/{promptId}/versions/{versionId}/refine\"", + 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); - ProcessRefinePromptResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RefinePrompt", + methodName: "RefinePromptAsync", + pathTemplate: "$\"/api/prompts/{promptId}/versions/{versionId}/refine\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.RefinedPromptResponse.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.RefinedPromptResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessRefinePromptResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RefinePrompt", + methodName: "RefinePromptAsync", + pathTemplate: "$\"/api/prompts/{promptId}/versions/{versionId}/refine\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RefinePrompt", + methodName: "RefinePromptAsync", + pathTemplate: "$\"/api/prompts/{promptId}/versions/{versionId}/refine\"", + 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); + ProcessRefinePromptResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.RefinedPromptResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.RefinedPromptResponse.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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(); + } } /// /// ✨ Refine a prompt version
@@ -253,6 +436,7 @@ partial void ProcessRefinePromptResponseContent( /// /// Model Provider Connection ID to use to refine the prompt /// + /// 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 RefinePromptAsync( @@ -262,6 +446,7 @@ partial void ProcessRefinePromptResponseContent( string teacherModelName, int teacherModelProviderConnectionId, bool? async = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.RefinePromptRequestRequest @@ -276,6 +461,7 @@ partial void ProcessRefinePromptResponseContent( promptId: promptId, versionId: versionId, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.PromptsClient.Update2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.PromptsClient.Update2.g.cs index 776d209..994c79f 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.PromptsClient.Update2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.PromptsClient.Update2.g.cs @@ -14,6 +14,7 @@ public partial class PromptsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -57,6 +58,7 @@ partial void ProcessUpdate2ResponseContent( /// /// /// + /// 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 Update2Async( @@ -64,6 +66,7 @@ partial void ProcessUpdate2ResponseContent( int versionId, global::LabelStudio.PatchedThirdPartyModelVersionRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -82,22 +85,43 @@ partial void ProcessUpdate2ResponseContent( securityRequirements: s_Update2SecurityRequirements, operationName: "Update2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/prompts/{promptId}/versions/{versionId}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/prompts/{promptId}/versions/{versionId}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -107,120 +131,279 @@ partial void ProcessUpdate2ResponseContent( __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); - PrepareUpdate2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - promptId: promptId, - versionId: versionId, - 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::LabelStudio.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); + PrepareUpdate2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + promptId: promptId, + versionId: versionId, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessUpdate2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/prompts/{promptId}/versions/{versionId}\"", + 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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/prompts/{promptId}/versions/{versionId}\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessUpdate2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/prompts/{promptId}/versions/{versionId}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.ThirdPartyModelVersion.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.ThirdPartyModelVersion.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessUpdate2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/prompts/{promptId}/versions/{versionId}\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/prompts/{promptId}/versions/{versionId}\"", + httpMethod: "PATCH", + 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); + ProcessUpdate2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.ThirdPartyModelVersion.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ThirdPartyModelVersion.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 prompt version
@@ -258,6 +441,7 @@ partial void ProcessUpdate2ResponseContent( /// /// Model name /// + /// 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 Update2Async( @@ -270,6 +454,7 @@ partial void ProcessUpdate2ResponseContent( global::LabelStudio.ProviderEnum? provider = default, string? providerModelId = default, string? title = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.PatchedThirdPartyModelVersionRequest @@ -287,6 +472,7 @@ partial void ProcessUpdate2ResponseContent( promptId: promptId, versionId: versionId, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.PromptsClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.PromptsClient.g.cs index 36efb95..4fe9d9d 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.PromptsClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.PromptsClient.g.cs @@ -30,6 +30,9 @@ public sealed partial class PromptsClient : global::LabelStudio.IPromptsClient, #if DEBUG = true; #endif + + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public PromptsClient( 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 PromptsClient. + /// 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 PromptsClient( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::LabelStudio.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::LabelStudio.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/LabelStudio/Generated/LabelStudio.Security.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Security.g.cs index c8b1e01..1a8faa9 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Security.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.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/LabelStudio/Generated/LabelStudio.SessionPolicyClient.Get.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.SessionPolicyClient.Get.g.cs index 051b49c..8ba66f1 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.SessionPolicyClient.Get.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.SessionPolicyClient.Get.g.cs @@ -14,6 +14,7 @@ public partial class SessionPolicyClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -42,9 +43,11 @@ partial void ProcessGetResponseContent( /// Retrieve Session Policy
/// Retrieve session timeout policy for the currently active 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 GetAsync( + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -58,22 +61,43 @@ partial void ProcessGetResponseContent( securityRequirements: s_GetSecurityRequirements, operationName: "GetAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/session-policy/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/session-policy/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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 ProcessGetResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetRequest( - 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); + PrepareGetRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "\"/api/session-policy/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "\"/api/session-policy/\"", + 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); - ProcessGetResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "\"/api/session-policy/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.SessionTimeoutPolicy.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.SessionTimeoutPolicy.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGetResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "\"/api/session-policy/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "\"/api/session-policy/\"", + 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); + ProcessGetResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.SessionTimeoutPolicy.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.SessionTimeoutPolicy.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.SessionPolicyClient.Update.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.SessionPolicyClient.Update.g.cs index 641037b..5979839 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.SessionPolicyClient.Update.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.SessionPolicyClient.Update.g.cs @@ -14,6 +14,7 @@ public partial class SessionPolicyClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,11 +46,13 @@ partial void ProcessUpdateResponseContent( /// Update session timeout policy for the currently active 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 UpdateAsync( global::LabelStudio.PatchedSessionTimeoutPolicyRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -66,22 +69,43 @@ partial void ProcessUpdateResponseContent( securityRequirements: s_UpdateSecurityRequirements, operationName: "UpdateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/session-policy/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/session-policy/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -91,118 +115,277 @@ partial void ProcessUpdateResponseContent( __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); - PrepareUpdateRequest( - 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::LabelStudio.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); + PrepareUpdateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessUpdateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "\"/api/session-policy/\"", + 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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "\"/api/session-policy/\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessUpdateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "\"/api/session-policy/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.SessionTimeoutPolicy.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.SessionTimeoutPolicy.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessUpdateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "\"/api/session-policy/\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "\"/api/session-policy/\"", + httpMethod: "PATCH", + 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); + ProcessUpdateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.SessionTimeoutPolicy.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.SessionTimeoutPolicy.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 Session Policy
@@ -214,11 +397,13 @@ partial void ProcessUpdateResponseContent( /// /// Number of minutes that a session stays active without any activity /// + /// 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 UpdateAsync( int? maxSessionAge = default, int? maxTimeBetweenActivity = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.PatchedSessionTimeoutPolicyRequest @@ -229,6 +414,7 @@ partial void ProcessUpdateResponseContent( return await UpdateAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.SessionPolicyClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.SessionPolicyClient.g.cs index b5c9537..a9c8d30 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.SessionPolicyClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.SessionPolicyClient.g.cs @@ -30,6 +30,9 @@ public sealed partial class SessionPolicyClient : global::LabelStudio.ISessionPo #if DEBUG = true; #endif + + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public SessionPolicyClient( 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 SessionPolicyClient. + /// 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 SessionPolicyClient( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::LabelStudio.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::LabelStudio.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/LabelStudio/Generated/LabelStudio.SsoClient.Get.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.SsoClient.Get.g.cs index a408b35..f4832a8 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.SsoClient.Get.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.SsoClient.Get.g.cs @@ -14,6 +14,7 @@ public partial class SsoClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -48,9 +49,11 @@ partial void ProcessGetResponseContent( /// </Card>
/// Retrieve SAML2 settings for the currently active 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 GetAsync( + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -64,22 +67,43 @@ partial void ProcessGetResponseContent( securityRequirements: s_GetSecurityRequirements, operationName: "GetAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/saml/settings", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/saml/settings", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,111 +113,270 @@ partial void ProcessGetResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetRequest( - 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); + PrepareGetRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "\"/api/saml/settings\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "\"/api/saml/settings\"", + 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); - ProcessGetResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "\"/api/saml/settings\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.SamlSettings.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.SamlSettings.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGetResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "\"/api/saml/settings\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "\"/api/saml/settings\"", + 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); + ProcessGetResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.SamlSettings.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.SamlSettings.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.SsoClient.Get2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.SsoClient.Get2.g.cs index a1ac33a..b2485e4 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.SsoClient.Get2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.SsoClient.Get2.g.cs @@ -14,6 +14,7 @@ public partial class SsoClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -48,9 +49,11 @@ partial void ProcessGet2ResponseContent( /// </Card>
/// Retrieve SCIM settings for the currently active 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 Get2Async( + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -64,22 +67,43 @@ partial void ProcessGet2ResponseContent( securityRequirements: s_Get2SecurityRequirements, operationName: "Get2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/scim/settings", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/scim/settings", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,111 +113,270 @@ partial void ProcessGet2ResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGet2Request( - 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); + PrepareGet2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGet2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "\"/api/scim/settings\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "\"/api/scim/settings\"", + 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); - ProcessGet2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "\"/api/scim/settings\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.ScimSettings.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.ScimSettings.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGet2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "\"/api/scim/settings\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "\"/api/scim/settings\"", + 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); + ProcessGet2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.ScimSettings.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ScimSettings.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.SsoClient.Reset.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.SsoClient.Reset.g.cs index 4e76865..3c1d8b8 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.SsoClient.Reset.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.SsoClient.Reset.g.cs @@ -14,6 +14,7 @@ public partial class SsoClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -43,9 +44,11 @@ partial void ProcessResetResponse( /// </Card>
/// Reset SAML2 settings for the currently active organization. This clears all configured fields (domain, metadata, attribute mappings, group mappings) back to their defaults without deleting the underlying settings record. /// + /// 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 ResetAsync( + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -59,22 +62,43 @@ partial void ProcessResetResponse( securityRequirements: s_ResetSecurityRequirements, operationName: "ResetAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/saml/settings", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/saml/settings", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -84,95 +108,254 @@ partial void ProcessResetResponse( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareResetRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareResetRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest); + + return __httpRequest; + } - using var __response = await HttpClient.SendAsync( + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Reset", + methodName: "ResetAsync", + pathTemplate: "\"/api/saml/settings\"", + 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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Reset", + methodName: "ResetAsync", + pathTemplate: "\"/api/saml/settings\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessResetResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Reset", + methodName: "ResetAsync", + pathTemplate: "\"/api/saml/settings\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessResetResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Reset", + methodName: "ResetAsync", + pathTemplate: "\"/api/saml/settings\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Reset", + methodName: "ResetAsync", + pathTemplate: "\"/api/saml/settings\"", + httpMethod: "DELETE", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.SsoClient.Update.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.SsoClient.Update.g.cs index e522e52..743e07c 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.SsoClient.Update.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.SsoClient.Update.g.cs @@ -14,6 +14,7 @@ public partial class SsoClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,11 +52,13 @@ partial void ProcessUpdateResponseContent( /// Update SAML2 settings for the currently active 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 UpdateAsync( global::LabelStudio.SamlSettingsUpdateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -72,22 +75,43 @@ partial void ProcessUpdateResponseContent( securityRequirements: s_UpdateSecurityRequirements, operationName: "UpdateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/saml/settings", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/saml/settings", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -97,118 +121,277 @@ partial void ProcessUpdateResponseContent( __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::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareUpdateRequest( - 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); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareUpdateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessUpdateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "\"/api/saml/settings\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "\"/api/saml/settings\"", + 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); - ProcessUpdateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "\"/api/saml/settings\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.SamlSettingsUpdate.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.SamlSettingsUpdate.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessUpdateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "\"/api/saml/settings\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "\"/api/saml/settings\"", + 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); + ProcessUpdateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.SamlSettingsUpdate.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.SamlSettingsUpdate.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 SAML2 Settings
@@ -256,6 +439,7 @@ partial void ProcessUpdateResponseContent( /// /// Workspaces to Groups Mapping. List of [workspace_title, group_name] 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 UpdateAsync( @@ -271,6 +455,7 @@ partial void ProcessUpdateResponseContent( global::System.Collections.Generic.IList? projectsGroups = default, global::System.Collections.Generic.IList>? rolesGroups = default, global::System.Collections.Generic.IList>? workspacesGroups = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.SamlSettingsUpdateRequest @@ -291,6 +476,7 @@ partial void ProcessUpdateResponseContent( return await UpdateAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.SsoClient.Update2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.SsoClient.Update2.g.cs index 5fa4e21..78ed408 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.SsoClient.Update2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.SsoClient.Update2.g.cs @@ -14,6 +14,7 @@ public partial class SsoClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,11 +52,13 @@ partial void ProcessUpdate2ResponseContent( /// Update SCIM settings for the currently active 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 Update2Async( global::LabelStudio.ScimSettingsUpdateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -72,22 +75,43 @@ partial void ProcessUpdate2ResponseContent( securityRequirements: s_Update2SecurityRequirements, operationName: "Update2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/scim/settings", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/scim/settings", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -97,118 +121,277 @@ partial void ProcessUpdate2ResponseContent( __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); - PrepareUpdate2Request( - 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::LabelStudio.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); + PrepareUpdate2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessUpdate2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "\"/api/scim/settings\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "\"/api/scim/settings\"", + 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); - ProcessUpdate2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "\"/api/scim/settings\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.ScimSettingsUpdate.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.ScimSettingsUpdate.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessUpdate2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "\"/api/scim/settings\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "\"/api/scim/settings\"", + 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); + ProcessUpdate2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.ScimSettingsUpdate.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ScimSettingsUpdate.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 SCIM Settings
@@ -229,12 +412,14 @@ partial void ProcessUpdate2ResponseContent( /// /// Workspaces to Groups Mapping. List of [workspace_title, group_name] 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 Update2Async( global::System.Collections.Generic.IList? projectsGroups = default, global::System.Collections.Generic.IList>? rolesGroups = default, global::System.Collections.Generic.IList>? workspacesGroups = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.ScimSettingsUpdateRequest @@ -246,6 +431,7 @@ partial void ProcessUpdate2ResponseContent( return await Update2Async( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.SsoClient.ValidateMetadataUrl.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.SsoClient.ValidateMetadataUrl.g.cs index 7473519..4c6242a 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.SsoClient.ValidateMetadataUrl.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.SsoClient.ValidateMetadataUrl.g.cs @@ -14,6 +14,7 @@ public partial class SsoClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,11 +52,13 @@ partial void ProcessValidateMetadataUrlResponseContent( /// Validate a SAML metadata URL by fetching it and checking for valid XML, without saving. ///
/// + /// 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 ValidateMetadataUrlAsync( global::LabelStudio.ValidateSamlMetadataUrlRequestRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -72,22 +75,43 @@ partial void ProcessValidateMetadataUrlResponseContent( securityRequirements: s_ValidateMetadataUrlSecurityRequirements, operationName: "ValidateMetadataUrlAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/saml/settings/validate-metadata-url", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/saml/settings/validate-metadata-url", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -97,118 +121,277 @@ partial void ProcessValidateMetadataUrlResponseContent( __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); - PrepareValidateMetadataUrlRequest( - 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::LabelStudio.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); + PrepareValidateMetadataUrlRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessValidateMetadataUrlResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ValidateMetadataUrl", + methodName: "ValidateMetadataUrlAsync", + pathTemplate: "\"/api/saml/settings/validate-metadata-url\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ValidateMetadataUrl", + methodName: "ValidateMetadataUrlAsync", + pathTemplate: "\"/api/saml/settings/validate-metadata-url\"", + 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); - ProcessValidateMetadataUrlResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ValidateMetadataUrl", + methodName: "ValidateMetadataUrlAsync", + pathTemplate: "\"/api/saml/settings/validate-metadata-url\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.ValidateSamlMetadataUrlResponse.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.ValidateSamlMetadataUrlResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessValidateMetadataUrlResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ValidateMetadataUrl", + methodName: "ValidateMetadataUrlAsync", + pathTemplate: "\"/api/saml/settings/validate-metadata-url\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ValidateMetadataUrl", + methodName: "ValidateMetadataUrlAsync", + pathTemplate: "\"/api/saml/settings/validate-metadata-url\"", + 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); + ProcessValidateMetadataUrlResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.ValidateSamlMetadataUrlResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ValidateSamlMetadataUrlResponse.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 SAML Metadata URL
@@ -221,10 +404,12 @@ partial void ProcessValidateMetadataUrlResponseContent( /// Validate a SAML metadata URL by fetching it and checking for valid XML, without saving. ///
/// + /// 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 ValidateMetadataUrlAsync( string metadataUrl, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.ValidateSamlMetadataUrlRequestRequest @@ -234,6 +419,7 @@ partial void ProcessValidateMetadataUrlResponseContent( return await ValidateMetadataUrlAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.SsoClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.SsoClient.g.cs index c06f2e4..e827f60 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.SsoClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.SsoClient.g.cs @@ -30,6 +30,9 @@ public sealed partial class SsoClient : global::LabelStudio.ISsoClient, global:: #if DEBUG = true; #endif + + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public SsoClient( 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 SsoClient. + /// 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 SsoClient( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::LabelStudio.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::LabelStudio.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StatesClient.CancelBackfill.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StatesClient.CancelBackfill.g.cs index b5112a0..0604783 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StatesClient.CancelBackfill.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StatesClient.CancelBackfill.g.cs @@ -14,6 +14,7 @@ public partial class StatesClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -54,11 +55,13 @@ partial void ProcessCancelBackfillResponseContent( /// /// /// + /// 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 CancelBackfillAsync( int? jobId = default, int? projectId = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -74,26 +77,47 @@ partial void ProcessCancelBackfillResponseContent( securityRequirements: s_CancelBackfillSecurityRequirements, operationName: "CancelBackfillAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/fsm/backfill/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("job_id", jobId?.ToString()) - .AddOptionalParameter("project_id", projectId?.ToString()) - ; - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/fsm/backfill/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("job_id", jobId?.ToString()) + .AddOptionalParameter("project_id", projectId?.ToString()) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -103,189 +127,348 @@ partial void ProcessCancelBackfillResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCancelBackfillRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - jobId: jobId, - projectId: projectId); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCancelBackfillRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + jobId: jobId, + projectId: projectId); - 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); - ProcessCancelBackfillResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // - if ((int)__response.StatusCode == 403) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_403 = null; - global::System.Exception? __exception_403 = null; - string? __value_403 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CancelBackfill", + methodName: "CancelBackfillAsync", + pathTemplate: "\"/api/fsm/backfill/\"", + 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_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, 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_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CancelBackfill", + methodName: "CancelBackfillAsync", + pathTemplate: "\"/api/fsm/backfill/\"", + 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_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - } - catch (global::System.Exception __ex) - { - __exception_403 = __ex; - } - throw new global::LabelStudio.ApiException( - message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_403, - statusCode: __response.StatusCode) - { - ResponseBody = __content_403, - ResponseObject = __value_403, - 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; - string? __value_404 = null; - try - { - if (ReadResponseAsString) + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_404 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(string), JsonSerializerContext); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CancelBackfill", + methodName: "CancelBackfillAsync", + pathTemplate: "\"/api/fsm/backfill/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else - { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_404 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(string), JsonSerializerContext); - } + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_404 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::LabelStudio.ApiException( - message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_404, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_404, - ResponseObject = __value_404, - 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); - ProcessCancelBackfillResponseContent( + response: __response); + ProcessCancelBackfillResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::LabelStudio.StateBackfillCancelResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CancelBackfill", + methodName: "CancelBackfillAsync", + pathTemplate: "\"/api/fsm/backfill/\"", + 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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CancelBackfill", + methodName: "CancelBackfillAsync", + pathTemplate: "\"/api/fsm/backfill/\"", + 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); + // + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + string? __value_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::LabelStudio.StateBackfillCancelResponse.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_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } + + throw new global::LabelStudio.ApiException( + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + statusCode: __response.StatusCode) + { + ResponseBody = __content_403, + ResponseObject = __value_403, + 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; + string? __value_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_404 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(string), JsonSerializerContext); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_404 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(string), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } + + throw new global::LabelStudio.ApiException( + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + statusCode: __response.StatusCode) + { + ResponseBody = __content_404, + ResponseObject = __value_404, + 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); + ProcessCancelBackfillResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.StateBackfillCancelResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.StateBackfillCancelResponse.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StatesClient.ExecuteTransition.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StatesClient.ExecuteTransition.g.cs index aa92f4c..bf0964c 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StatesClient.ExecuteTransition.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StatesClient.ExecuteTransition.g.cs @@ -14,6 +14,7 @@ public partial class StatesClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -57,6 +58,7 @@ partial void ProcessExecuteTransitionResponseContent( /// /// /// + /// 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 ExecuteTransitionAsync( @@ -64,6 +66,7 @@ partial void ProcessExecuteTransitionResponseContent( string entityName, global::LabelStudio.FSMTransitionExecuteRequestRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -82,22 +85,43 @@ partial void ProcessExecuteTransitionResponseContent( securityRequirements: s_ExecuteTransitionSecurityRequirements, operationName: "ExecuteTransitionAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/fsm/entities/{entityName}/{entityId}/transition/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/fsm/entities/{entityName}/{entityId}/transition/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -107,120 +131,279 @@ partial void ProcessExecuteTransitionResponseContent( __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); - PrepareExecuteTransitionRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - entityId: entityId, - entityName: entityName, - 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::LabelStudio.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); + PrepareExecuteTransitionRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + entityId: entityId, + entityName: entityName, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessExecuteTransitionResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ExecuteTransition", + methodName: "ExecuteTransitionAsync", + pathTemplate: "$\"/api/fsm/entities/{entityName}/{entityId}/transition/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ExecuteTransition", + methodName: "ExecuteTransitionAsync", + pathTemplate: "$\"/api/fsm/entities/{entityName}/{entityId}/transition/\"", + 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); - ProcessExecuteTransitionResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ExecuteTransition", + methodName: "ExecuteTransitionAsync", + pathTemplate: "$\"/api/fsm/entities/{entityName}/{entityId}/transition/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.FSMTransitionExecuteResponse.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.FSMTransitionExecuteResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessExecuteTransitionResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ExecuteTransition", + methodName: "ExecuteTransitionAsync", + pathTemplate: "$\"/api/fsm/entities/{entityName}/{entityId}/transition/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ExecuteTransition", + methodName: "ExecuteTransitionAsync", + pathTemplate: "$\"/api/fsm/entities/{entityName}/{entityId}/transition/\"", + 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); + ProcessExecuteTransitionResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.FSMTransitionExecuteResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.FSMTransitionExecuteResponse.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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(); + } } /// /// ✨ Execute manual state transition
@@ -236,6 +419,7 @@ partial void ProcessExecuteTransitionResponseContent( /// /// /// + /// 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 ExecuteTransitionAsync( @@ -243,6 +427,7 @@ partial void ProcessExecuteTransitionResponseContent( string entityName, string transitionName, object? transitionData = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.FSMTransitionExecuteRequestRequest @@ -255,6 +440,7 @@ partial void ProcessExecuteTransitionResponseContent( entityId: entityId, entityName: entityName, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StatesClient.GetBackfillStatus.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StatesClient.GetBackfillStatus.g.cs index 123f647..56bb558 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StatesClient.GetBackfillStatus.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StatesClient.GetBackfillStatus.g.cs @@ -14,6 +14,7 @@ public partial class StatesClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -54,11 +55,13 @@ partial void ProcessGetBackfillStatusResponseContent( ///
/// /// + /// 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 GetBackfillStatusAsync( int? jobId = default, int? projectId = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -74,26 +77,47 @@ partial void ProcessGetBackfillStatusResponseContent( securityRequirements: s_GetBackfillStatusSecurityRequirements, operationName: "GetBackfillStatusAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/fsm/backfill/status/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("job_id", jobId?.ToString()) - .AddOptionalParameter("project_id", projectId?.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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/fsm/backfill/status/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("job_id", jobId?.ToString()) + .AddOptionalParameter("project_id", projectId?.ToString()) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -103,189 +127,348 @@ partial void ProcessGetBackfillStatusResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetBackfillStatusRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - jobId: jobId, - projectId: projectId); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetBackfillStatusRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + jobId: jobId, + projectId: projectId); - 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); - ProcessGetBackfillStatusResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // - if ((int)__response.StatusCode == 403) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_403 = null; - global::System.Exception? __exception_403 = null; - string? __value_403 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetBackfillStatus", + methodName: "GetBackfillStatusAsync", + pathTemplate: "\"/api/fsm/backfill/status/\"", + 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_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, 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_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetBackfillStatus", + methodName: "GetBackfillStatusAsync", + pathTemplate: "\"/api/fsm/backfill/status/\"", + 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_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - } - catch (global::System.Exception __ex) - { - __exception_403 = __ex; - } - throw new global::LabelStudio.ApiException( - message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_403, - statusCode: __response.StatusCode) - { - ResponseBody = __content_403, - ResponseObject = __value_403, - 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; - string? __value_404 = null; - try - { - if (ReadResponseAsString) + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_404 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(string), JsonSerializerContext); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetBackfillStatus", + methodName: "GetBackfillStatusAsync", + pathTemplate: "\"/api/fsm/backfill/status/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else - { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_404 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(string), JsonSerializerContext); - } + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_404 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::LabelStudio.ApiException( - message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_404, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_404, - ResponseObject = __value_404, - 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); - ProcessGetBackfillStatusResponseContent( + response: __response); + ProcessGetBackfillStatusResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::LabelStudio.StateBackfillStatusResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetBackfillStatus", + methodName: "GetBackfillStatusAsync", + pathTemplate: "\"/api/fsm/backfill/status/\"", + 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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetBackfillStatus", + methodName: "GetBackfillStatusAsync", + pathTemplate: "\"/api/fsm/backfill/status/\"", + 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); + // + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + string? __value_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::LabelStudio.StateBackfillStatusResponse.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_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } + + throw new global::LabelStudio.ApiException( + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + statusCode: __response.StatusCode) + { + ResponseBody = __content_403, + ResponseObject = __value_403, + 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; + string? __value_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_404 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(string), JsonSerializerContext); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_404 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(string), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } + + throw new global::LabelStudio.ApiException( + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + statusCode: __response.StatusCode) + { + ResponseBody = __content_404, + ResponseObject = __value_404, + 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); + ProcessGetBackfillStatusResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.StateBackfillStatusResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.StateBackfillStatusResponse.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StatesClient.ListBackfills.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StatesClient.ListBackfills.g.cs index 7c2420f..7c7963b 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StatesClient.ListBackfills.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StatesClient.ListBackfills.g.cs @@ -14,6 +14,7 @@ public partial class StatesClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -48,9 +49,11 @@ partial void ProcessListBackfillsResponseContent( /// </Card>
/// Retrieve the latest 10 state backfill jobs for the authenticated user's active organization. Shows job history with status, progress, and timing information. Requires administrator or owner role and both FSM feature flags (fflag_feat_fit_568_finite_state_management and fflag_feat_fit_710_fsm_state_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 ListBackfillsAsync( + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -64,22 +67,43 @@ partial void ProcessListBackfillsResponseContent( securityRequirements: s_ListBackfillsSecurityRequirements, operationName: "ListBackfillsAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/fsm/backfill/jobs/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/fsm/backfill/jobs/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,225 +113,384 @@ partial void ProcessListBackfillsResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareListBackfillsRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareListBackfillsRequest( + 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); - ProcessListBackfillsResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // - if ((int)__response.StatusCode == 400) + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_400 = null; - global::System.Exception? __exception_400 = null; - string? __value_400 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListBackfills", + methodName: "ListBackfillsAsync", + pathTemplate: "\"/api/fsm/backfill/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_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, 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_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListBackfills", + methodName: "ListBackfillsAsync", + pathTemplate: "\"/api/fsm/backfill/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; + } - __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - } - catch (global::System.Exception __ex) - { - __exception_400 = __ex; - } - throw new global::LabelStudio.ApiException( - message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_400, - statusCode: __response.StatusCode) - { - ResponseBody = __content_400, - ResponseObject = __value_400, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // - if ((int)__response.StatusCode == 403) - { - string? __content_403 = null; - global::System.Exception? __exception_403 = null; - string? __value_403 = null; - try - { - if (ReadResponseAsString) + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListBackfills", + methodName: "ListBackfillsAsync", + pathTemplate: "\"/api/fsm/backfill/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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else - { - __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext); - } + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_403 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::LabelStudio.ApiException( - message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_403, - statusCode: __response.StatusCode) - { - ResponseBody = __content_403, - ResponseObject = __value_403, - 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; - string? __value_404 = null; - try + using (__response) { - if (ReadResponseAsString) - { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_404 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(string), JsonSerializerContext); - } - else - { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_404 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(string), JsonSerializerContext); - } + ProcessResponse( + client: HttpClient, + response: __response); + ProcessListBackfillsResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListBackfills", + methodName: "ListBackfillsAsync", + pathTemplate: "\"/api/fsm/backfill/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 { - __exception_404 = __ex; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListBackfills", + methodName: "ListBackfillsAsync", + pathTemplate: "\"/api/fsm/backfill/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); } + // + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + string? __value_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - throw new global::LabelStudio.ApiException( - message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_404, - statusCode: __response.StatusCode) - { - ResponseBody = __content_404, - ResponseObject = __value_404, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } + __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + throw new global::LabelStudio.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseObject = __value_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + string? __value_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessListBackfillsResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } - try - { - __response.EnsureSuccessStatusCode(); + throw new global::LabelStudio.ApiException( + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + statusCode: __response.StatusCode) + { + ResponseBody = __content_403, + ResponseObject = __value_403, + 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; + string? __value_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_404 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(string), JsonSerializerContext); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - global::LabelStudio.StateBackfillJobListResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); - } - catch (global::System.Exception __ex) - { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - cancellationToken -#endif - ).ConfigureAwait(false); + __value_404 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(string), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } - return - await global::LabelStudio.StateBackfillJobListResponse.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) - { - } + throw new global::LabelStudio.ApiException( + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + statusCode: __response.StatusCode) + { + ResponseBody = __content_404, + ResponseObject = __value_404, + 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); + ProcessListBackfillsResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.StateBackfillJobListResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.StateBackfillJobListResponse.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StatesClient.StateHistory.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StatesClient.StateHistory.g.cs index ae0b493..0819505 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StatesClient.StateHistory.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StatesClient.StateHistory.g.cs @@ -14,6 +14,7 @@ public partial class StatesClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -81,6 +82,7 @@ partial void ProcessStateHistoryResponseContent( /// /// /// + /// 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 StateHistoryAsync( @@ -95,6 +97,7 @@ partial void ProcessStateHistoryResponseContent( string? state = default, string? transitionName = default, double? triggeredBy = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -119,33 +122,54 @@ partial void ProcessStateHistoryResponseContent( securityRequirements: s_StateHistorySecurityRequirements, operationName: "StateHistoryAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/fsm/entities/{entityName}/{entityId}/history", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("created_at_from", createdAtFrom) - .AddOptionalParameter("created_at_to", createdAtTo) - .AddOptionalParameter("ordering", ordering) - .AddOptionalParameter("page", page?.ToString()) - .AddOptionalParameter("page_size", pageSize?.ToString()) - .AddOptionalParameter("previous_state", previousState) - .AddOptionalParameter("state", state) - .AddOptionalParameter("transition_name", transitionName) - .AddOptionalParameter("triggered_by", triggeredBy?.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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/fsm/entities/{entityName}/{entityId}/history", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("created_at_from", createdAtFrom) + .AddOptionalParameter("created_at_to", createdAtTo) + .AddOptionalParameter("ordering", ordering) + .AddOptionalParameter("page", page?.ToString()) + .AddOptionalParameter("page_size", pageSize?.ToString()) + .AddOptionalParameter("previous_state", previousState) + .AddOptionalParameter("state", state) + .AddOptionalParameter("transition_name", transitionName) + .AddOptionalParameter("triggered_by", triggeredBy?.ToString()) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,122 +179,281 @@ partial void ProcessStateHistoryResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareStateHistoryRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - createdAtFrom: createdAtFrom, - createdAtTo: createdAtTo, - entityId: entityId, - entityName: entityName, - ordering: ordering, - page: page, - pageSize: pageSize, - previousState: previousState, - state: state, - transitionName: transitionName, - triggeredBy: triggeredBy); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareStateHistoryRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + createdAtFrom: createdAtFrom, + createdAtTo: createdAtTo, + entityId: entityId, + entityName: entityName, + ordering: ordering, + page: page, + pageSize: pageSize, + previousState: previousState, + state: state, + transitionName: transitionName, + triggeredBy: triggeredBy); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessStateHistoryResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "StateHistory", + methodName: "StateHistoryAsync", + pathTemplate: "$\"/api/fsm/entities/{entityName}/{entityId}/history\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "StateHistory", + methodName: "StateHistoryAsync", + pathTemplate: "$\"/api/fsm/entities/{entityName}/{entityId}/history\"", + 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); - ProcessStateHistoryResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "StateHistory", + methodName: "StateHistoryAsync", + pathTemplate: "$\"/api/fsm/entities/{entityName}/{entityId}/history\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.PaginatedStateModelList.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.PaginatedStateModelList.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessStateHistoryResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "StateHistory", + methodName: "StateHistoryAsync", + pathTemplate: "$\"/api/fsm/entities/{entityName}/{entityId}/history\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "StateHistory", + methodName: "StateHistoryAsync", + pathTemplate: "$\"/api/fsm/entities/{entityName}/{entityId}/history\"", + 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); + ProcessStateHistoryResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.PaginatedStateModelList.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.PaginatedStateModelList.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StatesClient.TriggerBackfill.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StatesClient.TriggerBackfill.g.cs index ff9bf75..8ea9788 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StatesClient.TriggerBackfill.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StatesClient.TriggerBackfill.g.cs @@ -14,6 +14,7 @@ public partial class StatesClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,10 +52,12 @@ partial void ProcessTriggerBackfillResponseContent( /// Trigger state backfill for the authenticated user's active organization. Creates initial state records for entities without states. Requires administrator or owner role and both FSM feature flags (fflag_feat_fit_568_finite_state_management and fflag_feat_fit_710_fsm_state_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 TriggerBackfillAsync( int? projectId = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -69,25 +72,46 @@ partial void ProcessTriggerBackfillResponseContent( securityRequirements: s_TriggerBackfillSecurityRequirements, operationName: "TriggerBackfillAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/fsm/backfill/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("project_id", projectId?.ToString()) - ; - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/fsm/backfill/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("project_id", projectId?.ToString()) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -97,226 +121,385 @@ partial void ProcessTriggerBackfillResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareTriggerBackfillRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - projectId: projectId); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareTriggerBackfillRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + projectId: projectId); - 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); - ProcessTriggerBackfillResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // - if ((int)__response.StatusCode == 400) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_400 = null; - global::System.Exception? __exception_400 = null; - string? __value_400 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "TriggerBackfill", + methodName: "TriggerBackfillAsync", + pathTemplate: "\"/api/fsm/backfill/\"", + 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_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, 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_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "TriggerBackfill", + methodName: "TriggerBackfillAsync", + pathTemplate: "\"/api/fsm/backfill/\"", + 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_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - } - catch (global::System.Exception __ex) - { - __exception_400 = __ex; - } - throw new global::LabelStudio.ApiException( - message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_400, - statusCode: __response.StatusCode) - { - ResponseBody = __content_400, - ResponseObject = __value_400, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // - if ((int)__response.StatusCode == 403) - { - string? __content_403 = null; - global::System.Exception? __exception_403 = null; - string? __value_403 = null; - try - { - if (ReadResponseAsString) + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "TriggerBackfill", + methodName: "TriggerBackfillAsync", + pathTemplate: "\"/api/fsm/backfill/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else - { - __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext); - } + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_403 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::LabelStudio.ApiException( - message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_403, - statusCode: __response.StatusCode) - { - ResponseBody = __content_403, - ResponseObject = __value_403, - 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; - string? __value_404 = null; - try + using (__response) { - if (ReadResponseAsString) - { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_404 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(string), JsonSerializerContext); - } - else - { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_404 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(string), JsonSerializerContext); - } + ProcessResponse( + client: HttpClient, + response: __response); + ProcessTriggerBackfillResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "TriggerBackfill", + methodName: "TriggerBackfillAsync", + pathTemplate: "\"/api/fsm/backfill/\"", + 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 { - __exception_404 = __ex; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "TriggerBackfill", + methodName: "TriggerBackfillAsync", + pathTemplate: "\"/api/fsm/backfill/\"", + 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 ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + string? __value_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - throw new global::LabelStudio.ApiException( - message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_404, - statusCode: __response.StatusCode) - { - ResponseBody = __content_404, - ResponseObject = __value_404, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } + __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + throw new global::LabelStudio.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseObject = __value_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + string? __value_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessTriggerBackfillResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __value_403 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_403, typeof(string), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } - try - { - __response.EnsureSuccessStatusCode(); + throw new global::LabelStudio.ApiException( + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + statusCode: __response.StatusCode) + { + ResponseBody = __content_403, + ResponseObject = __value_403, + 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; + string? __value_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_404 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(string), JsonSerializerContext); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - global::LabelStudio.StateBackfillResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); - } - catch (global::System.Exception __ex) - { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - cancellationToken -#endif - ).ConfigureAwait(false); + __value_404 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(string), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } - return - await global::LabelStudio.StateBackfillResponse.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) - { - } + throw new global::LabelStudio.ApiException( + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + statusCode: __response.StatusCode) + { + ResponseBody = __content_404, + ResponseObject = __value_404, + 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); + ProcessTriggerBackfillResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.StateBackfillResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.StateBackfillResponse.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StatesClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StatesClient.g.cs index 6bad7b3..f29697c 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StatesClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StatesClient.g.cs @@ -30,6 +30,9 @@ public sealed partial class StatesClient : global::LabelStudio.IStatesClient, gl #if DEBUG = true; #endif + + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public StatesClient( 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 StatesClient. + /// 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 StatesClient( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::LabelStudio.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::LabelStudio.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StatsClient.AgreementAnnotator.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StatsClient.AgreementAnnotator.g.cs index 004d191..8ff5504 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StatsClient.AgreementAnnotator.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StatsClient.AgreementAnnotator.g.cs @@ -14,6 +14,7 @@ public partial class StatsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -54,11 +55,13 @@ partial void ProcessAgreementAnnotatorResponseContent( /// /// /// + /// 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 AgreementAnnotatorAsync( int id, int userId, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -74,22 +77,43 @@ partial void ProcessAgreementAnnotatorResponseContent( securityRequirements: s_AgreementAnnotatorSecurityRequirements, operationName: "AgreementAnnotatorAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{id}/stats/agreement_annotator/{userId}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{id}/stats/agreement_annotator/{userId}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -99,113 +123,272 @@ partial void ProcessAgreementAnnotatorResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareAgreementAnnotatorRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - userId: userId); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareAgreementAnnotatorRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + userId: userId); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessAgreementAnnotatorResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "AgreementAnnotator", + methodName: "AgreementAnnotatorAsync", + pathTemplate: "$\"/api/projects/{id}/stats/agreement_annotator/{userId}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "AgreementAnnotator", + methodName: "AgreementAnnotatorAsync", + pathTemplate: "$\"/api/projects/{id}/stats/agreement_annotator/{userId}\"", + 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); - ProcessAgreementAnnotatorResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "AgreementAnnotator", + methodName: "AgreementAnnotatorAsync", + pathTemplate: "$\"/api/projects/{id}/stats/agreement_annotator/{userId}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.ApiProjectsStatsAgreementAnnotatorRetrieveResponse.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.ApiProjectsStatsAgreementAnnotatorRetrieveResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessAgreementAnnotatorResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "AgreementAnnotator", + methodName: "AgreementAnnotatorAsync", + pathTemplate: "$\"/api/projects/{id}/stats/agreement_annotator/{userId}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "AgreementAnnotator", + methodName: "AgreementAnnotatorAsync", + pathTemplate: "$\"/api/projects/{id}/stats/agreement_annotator/{userId}\"", + 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); + ProcessAgreementAnnotatorResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.ApiProjectsStatsAgreementAnnotatorRetrieveResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiProjectsStatsAgreementAnnotatorRetrieveResponse.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StatsClient.AgreementAnnotators.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StatsClient.AgreementAnnotators.g.cs index 91bf175..ed55095 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StatsClient.AgreementAnnotators.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StatsClient.AgreementAnnotators.g.cs @@ -14,6 +14,7 @@ public partial class StatsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -54,11 +55,13 @@ partial void ProcessAgreementAnnotatorsResponseContent( /// /// /// + /// 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 AgreementAnnotatorsAsync( int id, string ids, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -74,25 +77,46 @@ partial void ProcessAgreementAnnotatorsResponseContent( securityRequirements: s_AgreementAnnotatorsSecurityRequirements, operationName: "AgreementAnnotatorsAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{id}/stats/agreement_annotators", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddRequiredParameter("ids", ids) - ; - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{id}/stats/agreement_annotators", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddRequiredParameter("ids", ids) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,113 +126,272 @@ partial void ProcessAgreementAnnotatorsResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareAgreementAnnotatorsRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - ids: ids); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareAgreementAnnotatorsRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + ids: ids); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessAgreementAnnotatorsResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "AgreementAnnotators", + methodName: "AgreementAnnotatorsAsync", + pathTemplate: "$\"/api/projects/{id}/stats/agreement_annotators\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "AgreementAnnotators", + methodName: "AgreementAnnotatorsAsync", + pathTemplate: "$\"/api/projects/{id}/stats/agreement_annotators\"", + 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); - ProcessAgreementAnnotatorsResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "AgreementAnnotators", + methodName: "AgreementAnnotatorsAsync", + pathTemplate: "$\"/api/projects/{id}/stats/agreement_annotators\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.ApiProjectsStatsAgreementAnnotatorsRetrieveResponse.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.ApiProjectsStatsAgreementAnnotatorsRetrieveResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessAgreementAnnotatorsResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "AgreementAnnotators", + methodName: "AgreementAnnotatorsAsync", + pathTemplate: "$\"/api/projects/{id}/stats/agreement_annotators\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "AgreementAnnotators", + methodName: "AgreementAnnotatorsAsync", + pathTemplate: "$\"/api/projects/{id}/stats/agreement_annotators\"", + 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); + ProcessAgreementAnnotatorsResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.ApiProjectsStatsAgreementAnnotatorsRetrieveResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiProjectsStatsAgreementAnnotatorsRetrieveResponse.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StatsClient.DataFilters.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StatsClient.DataFilters.g.cs index 3363dcf..fb7010e 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StatsClient.DataFilters.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StatsClient.DataFilters.g.cs @@ -14,6 +14,7 @@ public partial class StatsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,10 +52,12 @@ partial void ProcessDataFiltersResponseContent( /// Get statistics about user data filters and their usage within a project. /// /// + /// 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 DataFiltersAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -69,22 +72,43 @@ partial void ProcessDataFiltersResponseContent( securityRequirements: s_DataFiltersSecurityRequirements, operationName: "DataFiltersAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{id}/stats/data_filter", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{id}/stats/data_filter", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,112 +118,271 @@ partial void ProcessDataFiltersResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDataFiltersRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDataFiltersRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessDataFiltersResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DataFilters", + methodName: "DataFiltersAsync", + pathTemplate: "$\"/api/projects/{id}/stats/data_filter\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DataFilters", + methodName: "DataFiltersAsync", + pathTemplate: "$\"/api/projects/{id}/stats/data_filter\"", + 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); - ProcessDataFiltersResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DataFilters", + methodName: "DataFiltersAsync", + pathTemplate: "$\"/api/projects/{id}/stats/data_filter\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.ApiProjectsStatsDataFilterRetrieveResponse.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.ApiProjectsStatsDataFilterRetrieveResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessDataFiltersResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DataFilters", + methodName: "DataFiltersAsync", + pathTemplate: "$\"/api/projects/{id}/stats/data_filter\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DataFilters", + methodName: "DataFiltersAsync", + pathTemplate: "$\"/api/projects/{id}/stats/data_filter\"", + 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); + ProcessDataFiltersResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.ApiProjectsStatsDataFilterRetrieveResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiProjectsStatsDataFilterRetrieveResponse.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StatsClient.FinishedTasks.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StatsClient.FinishedTasks.g.cs index d9ec5b0..9d7c188 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StatsClient.FinishedTasks.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StatsClient.FinishedTasks.g.cs @@ -14,6 +14,7 @@ public partial class StatsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -54,11 +55,13 @@ partial void ProcessFinishedTasksResponseContent( /// /// /// + /// 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 FinishedTasksAsync( int id, int? userPk = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -74,25 +77,46 @@ partial void ProcessFinishedTasksResponseContent( securityRequirements: s_FinishedTasksSecurityRequirements, operationName: "FinishedTasksAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{id}/stats/finished", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("user_pk", userPk?.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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{id}/stats/finished", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("user_pk", userPk?.ToString()) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,113 +126,272 @@ partial void ProcessFinishedTasksResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareFinishedTasksRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - userPk: userPk); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareFinishedTasksRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + userPk: userPk); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessFinishedTasksResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "FinishedTasks", + methodName: "FinishedTasksAsync", + pathTemplate: "$\"/api/projects/{id}/stats/finished\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "FinishedTasks", + methodName: "FinishedTasksAsync", + pathTemplate: "$\"/api/projects/{id}/stats/finished\"", + 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); - ProcessFinishedTasksResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "FinishedTasks", + methodName: "FinishedTasksAsync", + pathTemplate: "$\"/api/projects/{id}/stats/finished\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.ApiProjectsStatsFinishedRetrieveResponse.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.ApiProjectsStatsFinishedRetrieveResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessFinishedTasksResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "FinishedTasks", + methodName: "FinishedTasksAsync", + pathTemplate: "$\"/api/projects/{id}/stats/finished\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "FinishedTasks", + methodName: "FinishedTasksAsync", + pathTemplate: "$\"/api/projects/{id}/stats/finished\"", + 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); + ProcessFinishedTasksResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.ApiProjectsStatsFinishedRetrieveResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiProjectsStatsFinishedRetrieveResponse.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StatsClient.Iaa.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StatsClient.Iaa.g.cs index cf96ab5..4f51de6 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StatsClient.Iaa.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StatsClient.Iaa.g.cs @@ -14,6 +14,7 @@ public partial class StatsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -67,6 +68,7 @@ partial void ProcessIaaResponseContent( /// 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 IaaAsync( @@ -75,6 +77,7 @@ partial void ProcessIaaResponseContent( bool? perLabel = default, bool? std = default, string? task = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -93,28 +96,49 @@ partial void ProcessIaaResponseContent( securityRequirements: s_IaaSecurityRequirements, operationName: "IaaAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{id}/stats/IAA", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("expand", expand) - .AddOptionalParameter("per_label", perLabel?.ToString().ToLowerInvariant()) - .AddOptionalParameter("std", std?.ToString().ToLowerInvariant()) - .AddOptionalParameter("task", task) - ; - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{id}/stats/IAA", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("expand", expand) + .AddOptionalParameter("per_label", perLabel?.ToString().ToLowerInvariant()) + .AddOptionalParameter("std", std?.ToString().ToLowerInvariant()) + .AddOptionalParameter("task", task) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -124,116 +148,275 @@ partial void ProcessIaaResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareIaaRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - expand: expand, - id: id, - perLabel: perLabel, - std: std, - task: task); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareIaaRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + expand: expand, + id: id, + perLabel: perLabel, + std: std, + task: task); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessIaaResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Iaa", + methodName: "IaaAsync", + pathTemplate: "$\"/api/projects/{id}/stats/IAA\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Iaa", + methodName: "IaaAsync", + pathTemplate: "$\"/api/projects/{id}/stats/IAA\"", + 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); - ProcessIaaResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Iaa", + methodName: "IaaAsync", + pathTemplate: "$\"/api/projects/{id}/stats/IAA\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.ApiProjectsStatsIaaRetrieveResponse.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.ApiProjectsStatsIaaRetrieveResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessIaaResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Iaa", + methodName: "IaaAsync", + pathTemplate: "$\"/api/projects/{id}/stats/IAA\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Iaa", + methodName: "IaaAsync", + pathTemplate: "$\"/api/projects/{id}/stats/IAA\"", + 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); + ProcessIaaResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.ApiProjectsStatsIaaRetrieveResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiProjectsStatsIaaRetrieveResponse.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StatsClient.LabelDistributionCounts.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StatsClient.LabelDistributionCounts.g.cs index b270f28..f882fff 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StatsClient.LabelDistributionCounts.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StatsClient.LabelDistributionCounts.g.cs @@ -14,6 +14,7 @@ public partial class StatsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -62,6 +63,7 @@ partial void ProcessLabelDistributionCountsResponseContent( /// /// 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 LabelDistributionCountsAsync( @@ -69,6 +71,7 @@ partial void ProcessLabelDistributionCountsResponseContent( string? choiceKeys = default, int? limit = default, int? offset = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -86,27 +89,48 @@ partial void ProcessLabelDistributionCountsResponseContent( securityRequirements: s_LabelDistributionCountsSecurityRequirements, operationName: "LabelDistributionCountsAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{id}/stats/label-distribution/counts", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("choice_keys", choiceKeys) - .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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{id}/stats/label-distribution/counts", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("choice_keys", choiceKeys) + .AddOptionalParameter("limit", limit?.ToString()) + .AddOptionalParameter("offset", offset?.ToString()) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -116,115 +140,274 @@ partial void ProcessLabelDistributionCountsResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareLabelDistributionCountsRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - choiceKeys: choiceKeys, - id: id, - limit: limit, - offset: offset); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareLabelDistributionCountsRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + choiceKeys: choiceKeys, + id: id, + limit: limit, + offset: offset); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessLabelDistributionCountsResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "LabelDistributionCounts", + methodName: "LabelDistributionCountsAsync", + pathTemplate: "$\"/api/projects/{id}/stats/label-distribution/counts\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "LabelDistributionCounts", + methodName: "LabelDistributionCountsAsync", + pathTemplate: "$\"/api/projects/{id}/stats/label-distribution/counts\"", + 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); - ProcessLabelDistributionCountsResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "LabelDistributionCounts", + methodName: "LabelDistributionCountsAsync", + pathTemplate: "$\"/api/projects/{id}/stats/label-distribution/counts\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.LabelDistributionCountsResponse.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.LabelDistributionCountsResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessLabelDistributionCountsResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "LabelDistributionCounts", + methodName: "LabelDistributionCountsAsync", + pathTemplate: "$\"/api/projects/{id}/stats/label-distribution/counts\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "LabelDistributionCounts", + methodName: "LabelDistributionCountsAsync", + pathTemplate: "$\"/api/projects/{id}/stats/label-distribution/counts\"", + 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); + ProcessLabelDistributionCountsResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.LabelDistributionCountsResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.LabelDistributionCountsResponse.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StatsClient.LabelDistributionStructure.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StatsClient.LabelDistributionStructure.g.cs index dbbf226..37f2f32 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StatsClient.LabelDistributionStructure.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StatsClient.LabelDistributionStructure.g.cs @@ -14,6 +14,7 @@ public partial class StatsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,10 +52,12 @@ partial void ProcessLabelDistributionStructureResponseContent( /// Returns dimensions and flattened `choice_keys` for a project. Use this response to drive paginated or targeted calls to the label distribution counts endpoint. /// /// + /// 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 LabelDistributionStructureAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -69,22 +72,43 @@ partial void ProcessLabelDistributionStructureResponseContent( securityRequirements: s_LabelDistributionStructureSecurityRequirements, operationName: "LabelDistributionStructureAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{id}/stats/label-distribution/structure", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{id}/stats/label-distribution/structure", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,112 +118,271 @@ partial void ProcessLabelDistributionStructureResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareLabelDistributionStructureRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareLabelDistributionStructureRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessLabelDistributionStructureResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "LabelDistributionStructure", + methodName: "LabelDistributionStructureAsync", + pathTemplate: "$\"/api/projects/{id}/stats/label-distribution/structure\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "LabelDistributionStructure", + methodName: "LabelDistributionStructureAsync", + pathTemplate: "$\"/api/projects/{id}/stats/label-distribution/structure\"", + 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); - ProcessLabelDistributionStructureResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "LabelDistributionStructure", + methodName: "LabelDistributionStructureAsync", + pathTemplate: "$\"/api/projects/{id}/stats/label-distribution/structure\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.LabelDistributionStructureResponse.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.LabelDistributionStructureResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessLabelDistributionStructureResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "LabelDistributionStructure", + methodName: "LabelDistributionStructureAsync", + pathTemplate: "$\"/api/projects/{id}/stats/label-distribution/structure\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "LabelDistributionStructure", + methodName: "LabelDistributionStructureAsync", + pathTemplate: "$\"/api/projects/{id}/stats/label-distribution/structure\"", + 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); + ProcessLabelDistributionStructureResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.LabelDistributionStructureResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.LabelDistributionStructureResponse.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StatsClient.LeadTime.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StatsClient.LeadTime.g.cs index 8406ccb..e2ccbfe 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StatsClient.LeadTime.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StatsClient.LeadTime.g.cs @@ -14,6 +14,7 @@ public partial class StatsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,10 +52,12 @@ partial void ProcessLeadTimeResponseContent( /// Get lead time statistics across the project, including average annotation time. /// /// + /// 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 LeadTimeAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -69,22 +72,43 @@ partial void ProcessLeadTimeResponseContent( securityRequirements: s_LeadTimeSecurityRequirements, operationName: "LeadTimeAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{id}/stats/lead_time", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{id}/stats/lead_time", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,112 +118,271 @@ partial void ProcessLeadTimeResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareLeadTimeRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareLeadTimeRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessLeadTimeResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "LeadTime", + methodName: "LeadTimeAsync", + pathTemplate: "$\"/api/projects/{id}/stats/lead_time\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "LeadTime", + methodName: "LeadTimeAsync", + pathTemplate: "$\"/api/projects/{id}/stats/lead_time\"", + 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); - ProcessLeadTimeResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "LeadTime", + methodName: "LeadTimeAsync", + pathTemplate: "$\"/api/projects/{id}/stats/lead_time\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.ApiProjectsStatsLeadTimeRetrieveResponse.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.ApiProjectsStatsLeadTimeRetrieveResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessLeadTimeResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "LeadTime", + methodName: "LeadTimeAsync", + pathTemplate: "$\"/api/projects/{id}/stats/lead_time\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "LeadTime", + methodName: "LeadTimeAsync", + pathTemplate: "$\"/api/projects/{id}/stats/lead_time\"", + 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); + ProcessLeadTimeResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.ApiProjectsStatsLeadTimeRetrieveResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiProjectsStatsLeadTimeRetrieveResponse.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StatsClient.ModelVersionAnnotatorAgreement.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StatsClient.ModelVersionAnnotatorAgreement.g.cs index 623bd61..16bfdc2 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StatsClient.ModelVersionAnnotatorAgreement.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StatsClient.ModelVersionAnnotatorAgreement.g.cs @@ -14,6 +14,7 @@ public partial class StatsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -54,11 +55,13 @@ partial void ProcessModelVersionAnnotatorAgreementResponseContent( /// /// /// + /// 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 ModelVersionAnnotatorAgreementAsync( int id, string modelVersion, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -74,22 +77,43 @@ partial void ProcessModelVersionAnnotatorAgreementResponseContent( securityRequirements: s_ModelVersionAnnotatorAgreementSecurityRequirements, operationName: "ModelVersionAnnotatorAgreementAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{id}/model-stats/{modelVersion}/agreement", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{id}/model-stats/{modelVersion}/agreement", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -99,113 +123,272 @@ partial void ProcessModelVersionAnnotatorAgreementResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareModelVersionAnnotatorAgreementRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - modelVersion: modelVersion); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareModelVersionAnnotatorAgreementRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + modelVersion: modelVersion); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessModelVersionAnnotatorAgreementResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ModelVersionAnnotatorAgreement", + methodName: "ModelVersionAnnotatorAgreementAsync", + pathTemplate: "$\"/api/projects/{id}/model-stats/{modelVersion}/agreement\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ModelVersionAnnotatorAgreement", + methodName: "ModelVersionAnnotatorAgreementAsync", + pathTemplate: "$\"/api/projects/{id}/model-stats/{modelVersion}/agreement\"", + 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); - ProcessModelVersionAnnotatorAgreementResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ModelVersionAnnotatorAgreement", + methodName: "ModelVersionAnnotatorAgreementAsync", + pathTemplate: "$\"/api/projects/{id}/model-stats/{modelVersion}/agreement\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.ApiProjectsModelStatsAgreementRetrieveResponse.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.ApiProjectsModelStatsAgreementRetrieveResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessModelVersionAnnotatorAgreementResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ModelVersionAnnotatorAgreement", + methodName: "ModelVersionAnnotatorAgreementAsync", + pathTemplate: "$\"/api/projects/{id}/model-stats/{modelVersion}/agreement\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ModelVersionAnnotatorAgreement", + methodName: "ModelVersionAnnotatorAgreementAsync", + pathTemplate: "$\"/api/projects/{id}/model-stats/{modelVersion}/agreement\"", + 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); + ProcessModelVersionAnnotatorAgreementResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.ApiProjectsModelStatsAgreementRetrieveResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiProjectsModelStatsAgreementRetrieveResponse.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StatsClient.ModelVersionGroundTruthAgreement.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StatsClient.ModelVersionGroundTruthAgreement.g.cs index 8675d74..df0e817 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StatsClient.ModelVersionGroundTruthAgreement.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StatsClient.ModelVersionGroundTruthAgreement.g.cs @@ -14,6 +14,7 @@ public partial class StatsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -59,12 +60,14 @@ partial void ProcessModelVersionGroundTruthAgreementResponseContent( /// /// 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 ModelVersionGroundTruthAgreementAsync( int id, string modelVersion, bool? perLabel = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -81,25 +84,46 @@ partial void ProcessModelVersionGroundTruthAgreementResponseContent( securityRequirements: s_ModelVersionGroundTruthAgreementSecurityRequirements, operationName: "ModelVersionGroundTruthAgreementAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{id}/model-stats/{modelVersion}/agreement-groundtruth", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("per_label", perLabel?.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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{id}/model-stats/{modelVersion}/agreement-groundtruth", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("per_label", perLabel?.ToString().ToLowerInvariant()) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -109,114 +133,273 @@ partial void ProcessModelVersionGroundTruthAgreementResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareModelVersionGroundTruthAgreementRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - modelVersion: modelVersion, - perLabel: perLabel); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareModelVersionGroundTruthAgreementRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + modelVersion: modelVersion, + perLabel: perLabel); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessModelVersionGroundTruthAgreementResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ModelVersionGroundTruthAgreement", + methodName: "ModelVersionGroundTruthAgreementAsync", + pathTemplate: "$\"/api/projects/{id}/model-stats/{modelVersion}/agreement-groundtruth\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ModelVersionGroundTruthAgreement", + methodName: "ModelVersionGroundTruthAgreementAsync", + pathTemplate: "$\"/api/projects/{id}/model-stats/{modelVersion}/agreement-groundtruth\"", + 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); - ProcessModelVersionGroundTruthAgreementResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ModelVersionGroundTruthAgreement", + methodName: "ModelVersionGroundTruthAgreementAsync", + pathTemplate: "$\"/api/projects/{id}/model-stats/{modelVersion}/agreement-groundtruth\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.ApiProjectsModelStatsAgreementGroundtruthRetrieveResponse.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.ApiProjectsModelStatsAgreementGroundtruthRetrieveResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessModelVersionGroundTruthAgreementResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ModelVersionGroundTruthAgreement", + methodName: "ModelVersionGroundTruthAgreementAsync", + pathTemplate: "$\"/api/projects/{id}/model-stats/{modelVersion}/agreement-groundtruth\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ModelVersionGroundTruthAgreement", + methodName: "ModelVersionGroundTruthAgreementAsync", + pathTemplate: "$\"/api/projects/{id}/model-stats/{modelVersion}/agreement-groundtruth\"", + 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); + ProcessModelVersionGroundTruthAgreementResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.ApiProjectsModelStatsAgreementGroundtruthRetrieveResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiProjectsModelStatsAgreementGroundtruthRetrieveResponse.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StatsClient.ModelVersionPredictionAgreement.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StatsClient.ModelVersionPredictionAgreement.g.cs index bcfdb6f..39a4a98 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StatsClient.ModelVersionPredictionAgreement.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StatsClient.ModelVersionPredictionAgreement.g.cs @@ -14,6 +14,7 @@ public partial class StatsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -59,12 +60,14 @@ partial void ProcessModelVersionPredictionAgreementResponseContent( /// /// 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 ModelVersionPredictionAgreementAsync( int id, string modelVersion, bool? perLabel = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -81,25 +84,46 @@ partial void ProcessModelVersionPredictionAgreementResponseContent( securityRequirements: s_ModelVersionPredictionAgreementSecurityRequirements, operationName: "ModelVersionPredictionAgreementAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{id}/model-stats/{modelVersion}/prediction", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("per_label", perLabel?.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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{id}/model-stats/{modelVersion}/prediction", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("per_label", perLabel?.ToString().ToLowerInvariant()) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -109,114 +133,273 @@ partial void ProcessModelVersionPredictionAgreementResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareModelVersionPredictionAgreementRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - modelVersion: modelVersion, - perLabel: perLabel); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareModelVersionPredictionAgreementRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + modelVersion: modelVersion, + perLabel: perLabel); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessModelVersionPredictionAgreementResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ModelVersionPredictionAgreement", + methodName: "ModelVersionPredictionAgreementAsync", + pathTemplate: "$\"/api/projects/{id}/model-stats/{modelVersion}/prediction\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ModelVersionPredictionAgreement", + methodName: "ModelVersionPredictionAgreementAsync", + pathTemplate: "$\"/api/projects/{id}/model-stats/{modelVersion}/prediction\"", + 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); - ProcessModelVersionPredictionAgreementResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ModelVersionPredictionAgreement", + methodName: "ModelVersionPredictionAgreementAsync", + pathTemplate: "$\"/api/projects/{id}/model-stats/{modelVersion}/prediction\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.ApiProjectsModelStatsPredictionRetrieveResponse.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.ApiProjectsModelStatsPredictionRetrieveResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessModelVersionPredictionAgreementResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ModelVersionPredictionAgreement", + methodName: "ModelVersionPredictionAgreementAsync", + pathTemplate: "$\"/api/projects/{id}/model-stats/{modelVersion}/prediction\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ModelVersionPredictionAgreement", + methodName: "ModelVersionPredictionAgreementAsync", + pathTemplate: "$\"/api/projects/{id}/model-stats/{modelVersion}/prediction\"", + 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); + ProcessModelVersionPredictionAgreementResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.ApiProjectsModelStatsPredictionRetrieveResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiProjectsModelStatsPredictionRetrieveResponse.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StatsClient.TotalAgreement.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StatsClient.TotalAgreement.g.cs index fc4dad9..cd77519 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StatsClient.TotalAgreement.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StatsClient.TotalAgreement.g.cs @@ -14,6 +14,7 @@ public partial class StatsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -55,11 +56,13 @@ partial void ProcessTotalAgreementResponseContent( /// /// /// + /// 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> TotalAgreementAsync( int id, bool? perLabel = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -75,25 +78,46 @@ partial void ProcessTotalAgreementResponseContent( securityRequirements: s_TotalAgreementSecurityRequirements, operationName: "TotalAgreementAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{id}/stats/total_agreement", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("per_label", perLabel?.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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{id}/stats/total_agreement", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("per_label", perLabel?.ToString().ToLowerInvariant()) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -103,113 +127,272 @@ partial void ProcessTotalAgreementResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareTotalAgreementRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - perLabel: perLabel); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareTotalAgreementRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + perLabel: perLabel); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessTotalAgreementResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "TotalAgreement", + methodName: "TotalAgreementAsync", + pathTemplate: "$\"/api/projects/{id}/stats/total_agreement\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "TotalAgreement", + methodName: "TotalAgreementAsync", + pathTemplate: "$\"/api/projects/{id}/stats/total_agreement\"", + 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); - ProcessTotalAgreementResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "TotalAgreement", + methodName: "TotalAgreementAsync", + pathTemplate: "$\"/api/projects/{id}/stats/total_agreement\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.OneOf.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.OneOf.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessTotalAgreementResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "TotalAgreement", + methodName: "TotalAgreementAsync", + pathTemplate: "$\"/api/projects/{id}/stats/total_agreement\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "TotalAgreement", + methodName: "TotalAgreementAsync", + pathTemplate: "$\"/api/projects/{id}/stats/total_agreement\"", + 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); + ProcessTotalAgreementResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.OneOf.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.OneOf.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StatsClient.UpdateStats.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StatsClient.UpdateStats.g.cs index bfe5fba..b202aad 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StatsClient.UpdateStats.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StatsClient.UpdateStats.g.cs @@ -14,6 +14,7 @@ public partial class StatsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -54,11 +55,13 @@ partial void ProcessUpdateStatsResponseContent( /// /// /// + /// 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 UpdateStatsAsync( int id, string? statType = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -74,25 +77,46 @@ partial void ProcessUpdateStatsResponseContent( securityRequirements: s_UpdateStatsSecurityRequirements, operationName: "UpdateStatsAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{id}/update-stats", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("stat_type", statType) - ; - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{id}/update-stats", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("stat_type", statType) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,109 +126,268 @@ partial void ProcessUpdateStatsResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareUpdateStatsRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - statType: statType); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareUpdateStatsRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + statType: statType); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessUpdateStatsResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateStats", + methodName: "UpdateStatsAsync", + pathTemplate: "$\"/api/projects/{id}/update-stats\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateStats", + methodName: "UpdateStatsAsync", + pathTemplate: "$\"/api/projects/{id}/update-stats\"", + 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); - ProcessUpdateStatsResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateStats", + methodName: "UpdateStatsAsync", + pathTemplate: "$\"/api/projects/{id}/update-stats\"", + 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::LabelStudio.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::LabelStudio.ApiException( - message: __content ?? __response.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); + ProcessUpdateStatsResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateStats", + methodName: "UpdateStatsAsync", + pathTemplate: "$\"/api/projects/{id}/update-stats\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateStats", + methodName: "UpdateStatsAsync", + pathTemplate: "$\"/api/projects/{id}/update-stats\"", + 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); + ProcessUpdateStatsResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return __content; + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StatsClient.UserGroundTruthAgreement.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StatsClient.UserGroundTruthAgreement.g.cs index 18eb2c2..1622a32 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StatsClient.UserGroundTruthAgreement.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StatsClient.UserGroundTruthAgreement.g.cs @@ -14,6 +14,7 @@ public partial class StatsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -57,12 +58,14 @@ partial void ProcessUserGroundTruthAgreementResponseContent( /// /// /// + /// 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 UserGroundTruthAgreementAsync( int id, int userPk, bool? perLabel = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -79,25 +82,46 @@ partial void ProcessUserGroundTruthAgreementResponseContent( securityRequirements: s_UserGroundTruthAgreementSecurityRequirements, operationName: "UserGroundTruthAgreementAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{id}/users/{userPk}/stats/agreement-groundtruth", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("per_label", perLabel?.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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{id}/users/{userPk}/stats/agreement-groundtruth", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("per_label", perLabel?.ToString().ToLowerInvariant()) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,114 +131,273 @@ partial void ProcessUserGroundTruthAgreementResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareUserGroundTruthAgreementRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - perLabel: perLabel, - userPk: userPk); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareUserGroundTruthAgreementRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + perLabel: perLabel, + userPk: userPk); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessUserGroundTruthAgreementResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UserGroundTruthAgreement", + methodName: "UserGroundTruthAgreementAsync", + pathTemplate: "$\"/api/projects/{id}/users/{userPk}/stats/agreement-groundtruth\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UserGroundTruthAgreement", + methodName: "UserGroundTruthAgreementAsync", + pathTemplate: "$\"/api/projects/{id}/users/{userPk}/stats/agreement-groundtruth\"", + 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); - ProcessUserGroundTruthAgreementResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UserGroundTruthAgreement", + methodName: "UserGroundTruthAgreementAsync", + pathTemplate: "$\"/api/projects/{id}/users/{userPk}/stats/agreement-groundtruth\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.ApiProjectsUsersStatsAgreementGroundtruthRetrieveResponse.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.ApiProjectsUsersStatsAgreementGroundtruthRetrieveResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessUserGroundTruthAgreementResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UserGroundTruthAgreement", + methodName: "UserGroundTruthAgreementAsync", + pathTemplate: "$\"/api/projects/{id}/users/{userPk}/stats/agreement-groundtruth\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UserGroundTruthAgreement", + methodName: "UserGroundTruthAgreementAsync", + pathTemplate: "$\"/api/projects/{id}/users/{userPk}/stats/agreement-groundtruth\"", + 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); + ProcessUserGroundTruthAgreementResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.ApiProjectsUsersStatsAgreementGroundtruthRetrieveResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiProjectsUsersStatsAgreementGroundtruthRetrieveResponse.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StatsClient.UserPredictionAgreement.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StatsClient.UserPredictionAgreement.g.cs index acd56b7..0d1855c 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StatsClient.UserPredictionAgreement.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StatsClient.UserPredictionAgreement.g.cs @@ -14,6 +14,7 @@ public partial class StatsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -57,12 +58,14 @@ partial void ProcessUserPredictionAgreementResponseContent( /// /// /// + /// 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 UserPredictionAgreementAsync( int id, int userPk, bool? perLabel = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -79,25 +82,46 @@ partial void ProcessUserPredictionAgreementResponseContent( securityRequirements: s_UserPredictionAgreementSecurityRequirements, operationName: "UserPredictionAgreementAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{id}/user-stats/{userPk}/prediction", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("per_label", perLabel?.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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{id}/user-stats/{userPk}/prediction", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("per_label", perLabel?.ToString().ToLowerInvariant()) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,114 +131,273 @@ partial void ProcessUserPredictionAgreementResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareUserPredictionAgreementRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - perLabel: perLabel, - userPk: userPk); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareUserPredictionAgreementRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + perLabel: perLabel, + userPk: userPk); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessUserPredictionAgreementResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UserPredictionAgreement", + methodName: "UserPredictionAgreementAsync", + pathTemplate: "$\"/api/projects/{id}/user-stats/{userPk}/prediction\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UserPredictionAgreement", + methodName: "UserPredictionAgreementAsync", + pathTemplate: "$\"/api/projects/{id}/user-stats/{userPk}/prediction\"", + 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); - ProcessUserPredictionAgreementResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UserPredictionAgreement", + methodName: "UserPredictionAgreementAsync", + pathTemplate: "$\"/api/projects/{id}/user-stats/{userPk}/prediction\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.ApiProjectsUserStatsPredictionRetrieve2Response.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.ApiProjectsUserStatsPredictionRetrieve2Response.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessUserPredictionAgreementResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UserPredictionAgreement", + methodName: "UserPredictionAgreementAsync", + pathTemplate: "$\"/api/projects/{id}/user-stats/{userPk}/prediction\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UserPredictionAgreement", + methodName: "UserPredictionAgreementAsync", + pathTemplate: "$\"/api/projects/{id}/user-stats/{userPk}/prediction\"", + 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); + ProcessUserPredictionAgreementResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.ApiProjectsUserStatsPredictionRetrieve2Response.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiProjectsUserStatsPredictionRetrieve2Response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StatsClient.UserReviewScore.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StatsClient.UserReviewScore.g.cs index 313848c..87b9300 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StatsClient.UserReviewScore.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StatsClient.UserReviewScore.g.cs @@ -14,6 +14,7 @@ public partial class StatsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -57,12 +58,14 @@ partial void ProcessUserReviewScoreResponseContent( /// /// /// + /// 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 UserReviewScoreAsync( int id, int userPk, bool? perLabel = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -79,25 +82,46 @@ partial void ProcessUserReviewScoreResponseContent( securityRequirements: s_UserReviewScoreSecurityRequirements, operationName: "UserReviewScoreAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{id}/user-stats/{userPk}/review_score", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("per_label", perLabel?.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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{id}/user-stats/{userPk}/review_score", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("per_label", perLabel?.ToString().ToLowerInvariant()) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,114 +131,273 @@ partial void ProcessUserReviewScoreResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareUserReviewScoreRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - perLabel: perLabel, - userPk: userPk); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareUserReviewScoreRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + perLabel: perLabel, + userPk: userPk); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessUserReviewScoreResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UserReviewScore", + methodName: "UserReviewScoreAsync", + pathTemplate: "$\"/api/projects/{id}/user-stats/{userPk}/review_score\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UserReviewScore", + methodName: "UserReviewScoreAsync", + pathTemplate: "$\"/api/projects/{id}/user-stats/{userPk}/review_score\"", + 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); - ProcessUserReviewScoreResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UserReviewScore", + methodName: "UserReviewScoreAsync", + pathTemplate: "$\"/api/projects/{id}/user-stats/{userPk}/review_score\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.ApiProjectsUserStatsReviewScoreRetrieve2Response.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.ApiProjectsUserStatsReviewScoreRetrieve2Response.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessUserReviewScoreResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UserReviewScore", + methodName: "UserReviewScoreAsync", + pathTemplate: "$\"/api/projects/{id}/user-stats/{userPk}/review_score\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UserReviewScore", + methodName: "UserReviewScoreAsync", + pathTemplate: "$\"/api/projects/{id}/user-stats/{userPk}/review_score\"", + 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); + ProcessUserReviewScoreResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.ApiProjectsUserStatsReviewScoreRetrieve2Response.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiProjectsUserStatsReviewScoreRetrieve2Response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StatsClient.UsersGroundTruthAgreement.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StatsClient.UsersGroundTruthAgreement.g.cs index cbd37e4..4af5f16 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StatsClient.UsersGroundTruthAgreement.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StatsClient.UsersGroundTruthAgreement.g.cs @@ -14,6 +14,7 @@ public partial class StatsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -59,12 +60,14 @@ partial void ProcessUsersGroundTruthAgreementResponseContent( /// /// 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 UsersGroundTruthAgreementAsync( int id, string ids, bool? perLabel = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -81,26 +84,47 @@ partial void ProcessUsersGroundTruthAgreementResponseContent( securityRequirements: s_UsersGroundTruthAgreementSecurityRequirements, operationName: "UsersGroundTruthAgreementAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{id}/stats/agreement-groundtruth", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddRequiredParameter("ids", ids) - .AddOptionalParameter("per_label", perLabel?.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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{id}/stats/agreement-groundtruth", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddRequiredParameter("ids", ids) + .AddOptionalParameter("per_label", perLabel?.ToString().ToLowerInvariant()) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -110,114 +134,273 @@ partial void ProcessUsersGroundTruthAgreementResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareUsersGroundTruthAgreementRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - ids: ids, - perLabel: perLabel); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareUsersGroundTruthAgreementRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + ids: ids, + perLabel: perLabel); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessUsersGroundTruthAgreementResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UsersGroundTruthAgreement", + methodName: "UsersGroundTruthAgreementAsync", + pathTemplate: "$\"/api/projects/{id}/stats/agreement-groundtruth\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UsersGroundTruthAgreement", + methodName: "UsersGroundTruthAgreementAsync", + pathTemplate: "$\"/api/projects/{id}/stats/agreement-groundtruth\"", + 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); - ProcessUsersGroundTruthAgreementResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UsersGroundTruthAgreement", + methodName: "UsersGroundTruthAgreementAsync", + pathTemplate: "$\"/api/projects/{id}/stats/agreement-groundtruth\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.ApiProjectsStatsAgreementGroundtruthRetrieveResponse.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.ApiProjectsStatsAgreementGroundtruthRetrieveResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessUsersGroundTruthAgreementResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UsersGroundTruthAgreement", + methodName: "UsersGroundTruthAgreementAsync", + pathTemplate: "$\"/api/projects/{id}/stats/agreement-groundtruth\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UsersGroundTruthAgreement", + methodName: "UsersGroundTruthAgreementAsync", + pathTemplate: "$\"/api/projects/{id}/stats/agreement-groundtruth\"", + 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); + ProcessUsersGroundTruthAgreementResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.ApiProjectsStatsAgreementGroundtruthRetrieveResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiProjectsStatsAgreementGroundtruthRetrieveResponse.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StatsClient.UsersPredictionAgreement.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StatsClient.UsersPredictionAgreement.g.cs index 42be430..462624d 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StatsClient.UsersPredictionAgreement.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StatsClient.UsersPredictionAgreement.g.cs @@ -14,6 +14,7 @@ public partial class StatsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -59,12 +60,14 @@ partial void ProcessUsersPredictionAgreementResponseContent( /// /// 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 UsersPredictionAgreementAsync( int id, string ids, bool? perLabel = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -81,26 +84,47 @@ partial void ProcessUsersPredictionAgreementResponseContent( securityRequirements: s_UsersPredictionAgreementSecurityRequirements, operationName: "UsersPredictionAgreementAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{id}/user-stats/prediction", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddRequiredParameter("ids", ids) - .AddOptionalParameter("per_label", perLabel?.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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{id}/user-stats/prediction", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddRequiredParameter("ids", ids) + .AddOptionalParameter("per_label", perLabel?.ToString().ToLowerInvariant()) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -110,114 +134,273 @@ partial void ProcessUsersPredictionAgreementResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareUsersPredictionAgreementRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - ids: ids, - perLabel: perLabel); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareUsersPredictionAgreementRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + ids: ids, + perLabel: perLabel); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessUsersPredictionAgreementResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UsersPredictionAgreement", + methodName: "UsersPredictionAgreementAsync", + pathTemplate: "$\"/api/projects/{id}/user-stats/prediction\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UsersPredictionAgreement", + methodName: "UsersPredictionAgreementAsync", + pathTemplate: "$\"/api/projects/{id}/user-stats/prediction\"", + 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); - ProcessUsersPredictionAgreementResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UsersPredictionAgreement", + methodName: "UsersPredictionAgreementAsync", + pathTemplate: "$\"/api/projects/{id}/user-stats/prediction\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.ApiProjectsUserStatsPredictionRetrieveResponse.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.ApiProjectsUserStatsPredictionRetrieveResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessUsersPredictionAgreementResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UsersPredictionAgreement", + methodName: "UsersPredictionAgreementAsync", + pathTemplate: "$\"/api/projects/{id}/user-stats/prediction\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UsersPredictionAgreement", + methodName: "UsersPredictionAgreementAsync", + pathTemplate: "$\"/api/projects/{id}/user-stats/prediction\"", + 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); + ProcessUsersPredictionAgreementResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.ApiProjectsUserStatsPredictionRetrieveResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiProjectsUserStatsPredictionRetrieveResponse.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StatsClient.UsersReviewScore.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StatsClient.UsersReviewScore.g.cs index 18791dd..2b7cbe8 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StatsClient.UsersReviewScore.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StatsClient.UsersReviewScore.g.cs @@ -14,6 +14,7 @@ public partial class StatsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -57,12 +58,14 @@ partial void ProcessUsersReviewScoreResponseContent( /// /// /// + /// 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 UsersReviewScoreAsync( int id, string ids, bool? perLabel = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -79,26 +82,47 @@ partial void ProcessUsersReviewScoreResponseContent( securityRequirements: s_UsersReviewScoreSecurityRequirements, operationName: "UsersReviewScoreAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{id}/user-stats/review_score", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddRequiredParameter("ids", ids) - .AddOptionalParameter("per_label", perLabel?.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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{id}/user-stats/review_score", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddRequiredParameter("ids", ids) + .AddOptionalParameter("per_label", perLabel?.ToString().ToLowerInvariant()) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -108,114 +132,273 @@ partial void ProcessUsersReviewScoreResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareUsersReviewScoreRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - ids: ids, - perLabel: perLabel); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareUsersReviewScoreRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + ids: ids, + perLabel: perLabel); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessUsersReviewScoreResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UsersReviewScore", + methodName: "UsersReviewScoreAsync", + pathTemplate: "$\"/api/projects/{id}/user-stats/review_score\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UsersReviewScore", + methodName: "UsersReviewScoreAsync", + pathTemplate: "$\"/api/projects/{id}/user-stats/review_score\"", + 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); - ProcessUsersReviewScoreResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UsersReviewScore", + methodName: "UsersReviewScoreAsync", + pathTemplate: "$\"/api/projects/{id}/user-stats/review_score\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.ApiProjectsUserStatsReviewScoreRetrieveResponse.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.ApiProjectsUserStatsReviewScoreRetrieveResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessUsersReviewScoreResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UsersReviewScore", + methodName: "UsersReviewScoreAsync", + pathTemplate: "$\"/api/projects/{id}/user-stats/review_score\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UsersReviewScore", + methodName: "UsersReviewScoreAsync", + pathTemplate: "$\"/api/projects/{id}/user-stats/review_score\"", + 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); + ProcessUsersReviewScoreResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.ApiProjectsUserStatsReviewScoreRetrieveResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiProjectsUserStatsReviewScoreRetrieveResponse.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StatsClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StatsClient.g.cs index a6e4b57..b14e535 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StatsClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StatsClient.g.cs @@ -30,6 +30,9 @@ public sealed partial class StatsClient : global::LabelStudio.IStatsClient, glob #if DEBUG = true; #endif + + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public StatsClient( 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 StatsClient. + /// 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 StatsClient( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::LabelStudio.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::LabelStudio.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureClient.Create.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureClient.Create.g.cs index c74b75e..57a20ea 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureClient.Create.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureClient.Create.g.cs @@ -14,6 +14,7 @@ public partial class StorageAzureClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,11 +46,13 @@ partial void ProcessCreateResponseContent( /// Create new Azure import 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 CreateAsync( global::LabelStudio.ApiStoragesAzureCreateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -66,22 +69,43 @@ partial void ProcessCreateResponseContent( securityRequirements: s_CreateSecurityRequirements, operationName: "CreateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/storages/azure/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/storages/azure/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,118 +115,277 @@ partial void ProcessCreateResponseContent( __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::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCreateRequest( - 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); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/storages/azure/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/storages/azure/\"", + 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); - ProcessCreateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/storages/azure/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.AzureBlobImportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.AzureBlobImportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessCreateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/storages/azure/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/storages/azure/\"", + 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); + ProcessCreateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.AzureBlobImportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.AzureBlobImportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 new storage
@@ -244,6 +427,7 @@ partial void ProcessCreateResponseContent( /// Interpret objects as BLOBs and generate URLs. For example, if your bucket contains images, you can use this option to generate URLs for these images. If set to False, it will read the content of the file and load it into Label Studio.
/// 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 CreateAsync( @@ -258,6 +442,7 @@ partial void ProcessCreateResponseContent( string? regexFilter = default, string? title = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.ApiStoragesAzureCreateRequest @@ -277,6 +462,7 @@ partial void ProcessCreateResponseContent( return await CreateAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureClient.Create2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureClient.Create2.g.cs index be7d838..079639a 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureClient.Create2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureClient.Create2.g.cs @@ -14,6 +14,7 @@ public partial class StorageAzureClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,11 +46,13 @@ partial void ProcessCreate2ResponseContent( /// Create a new Azure export storage connection to store annotations. ///
/// + /// 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 Create2Async( global::LabelStudio.ApiStoragesExportAzureCreateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -66,22 +69,43 @@ partial void ProcessCreate2ResponseContent( securityRequirements: s_Create2SecurityRequirements, operationName: "Create2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/storages/export/azure", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/storages/export/azure", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,118 +115,277 @@ partial void ProcessCreate2ResponseContent( __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::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCreate2Request( - 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); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreate2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreate2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "\"/api/storages/export/azure\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "\"/api/storages/export/azure\"", + 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); - ProcessCreate2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "\"/api/storages/export/azure\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.AzureBlobExportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.AzureBlobExportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessCreate2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "\"/api/storages/export/azure\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "\"/api/storages/export/azure\"", + 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); + ProcessCreate2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.AzureBlobExportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.AzureBlobExportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 export storage
@@ -233,6 +416,7 @@ partial void ProcessCreate2ResponseContent( /// /// Storage title /// + /// 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 Create2Async( @@ -244,6 +428,7 @@ partial void ProcessCreate2ResponseContent( string? prefix = default, int? project = default, string? title = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.ApiStoragesExportAzureCreateRequest @@ -260,6 +445,7 @@ partial void ProcessCreate2ResponseContent( return await Create2Async( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureClient.Delete.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureClient.Delete.g.cs index 1da9e14..e7d7b5d 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureClient.Delete.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureClient.Delete.g.cs @@ -14,6 +14,7 @@ public partial class StorageAzureClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -40,10 +41,12 @@ partial void ProcessDeleteResponse( /// Delete a specific Azure import storage connection. ///
/// + /// 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 DeleteAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -58,22 +61,43 @@ partial void ProcessDeleteResponse( securityRequirements: s_DeleteSecurityRequirements, operationName: "DeleteAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/azure/{id}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/azure/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -83,96 +107,255 @@ partial void ProcessDeleteResponse( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDeleteRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDeleteRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/storages/azure/{id}\"", + 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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/storages/azure/{id}\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessDeleteResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/storages/azure/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessDeleteResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/storages/azure/{id}\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/storages/azure/{id}\"", + httpMethod: "DELETE", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageAzureClient.Delete2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureClient.Delete2.g.cs index 1aa3cfd..fe06097 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureClient.Delete2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureClient.Delete2.g.cs @@ -14,6 +14,7 @@ public partial class StorageAzureClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -40,10 +41,12 @@ partial void ProcessDelete2Response( /// Delete a specific Azure export storage connection. /// /// + /// 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 Delete2Async( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -58,22 +61,43 @@ partial void ProcessDelete2Response( securityRequirements: s_Delete2SecurityRequirements, operationName: "Delete2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/export/azure/{id}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/export/azure/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -83,96 +107,255 @@ partial void ProcessDelete2Response( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDelete2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDelete2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/storages/export/azure/{id}\"", + 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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/storages/export/azure/{id}\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessDelete2Response( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/storages/export/azure/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessDelete2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/storages/export/azure/{id}\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/storages/export/azure/{id}\"", + httpMethod: "DELETE", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageAzureClient.Get.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureClient.Get.g.cs index c1b618d..612170e 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureClient.Get.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureClient.Get.g.cs @@ -14,6 +14,7 @@ public partial class StorageAzureClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,10 +46,12 @@ partial void ProcessGetResponseContent( /// Get a specific Azure import storage connection. /// /// + /// 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 GetAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -63,22 +66,43 @@ partial void ProcessGetResponseContent( securityRequirements: s_GetSecurityRequirements, operationName: "GetAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/azure/{id}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/azure/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -88,112 +112,271 @@ partial void ProcessGetResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/storages/azure/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/storages/azure/{id}\"", + 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); - ProcessGetResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/storages/azure/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.AzureBlobImportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.AzureBlobImportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGetResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/storages/azure/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/storages/azure/{id}\"", + 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); + ProcessGetResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.AzureBlobImportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.AzureBlobImportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageAzureClient.Get2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureClient.Get2.g.cs index 3c7189d..a9a14d9 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureClient.Get2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureClient.Get2.g.cs @@ -14,6 +14,7 @@ public partial class StorageAzureClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,10 +46,12 @@ partial void ProcessGet2ResponseContent( /// Get a specific Azure export storage connection. /// /// + /// 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 Get2Async( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -63,22 +66,43 @@ partial void ProcessGet2ResponseContent( securityRequirements: s_Get2SecurityRequirements, operationName: "Get2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/export/azure/{id}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/export/azure/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -88,112 +112,271 @@ partial void ProcessGet2ResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGet2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGet2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGet2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "$\"/api/storages/export/azure/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "$\"/api/storages/export/azure/{id}\"", + 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); - ProcessGet2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "$\"/api/storages/export/azure/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.AzureBlobExportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.AzureBlobExportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGet2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "$\"/api/storages/export/azure/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "$\"/api/storages/export/azure/{id}\"", + 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); + ProcessGet2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.AzureBlobExportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.AzureBlobExportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageAzureClient.List.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureClient.List.g.cs index 567d982..5b434c4 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureClient.List.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureClient.List.g.cs @@ -14,6 +14,7 @@ public partial class StorageAzureClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -48,11 +49,13 @@ partial void ProcessListResponseContent( /// /// /// + /// 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> ListAsync( int project, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -68,26 +71,47 @@ partial void ProcessListResponseContent( securityRequirements: s_ListSecurityRequirements, operationName: "ListAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/storages/azure/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("ordering", ordering) - .AddRequiredParameter("project", project.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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/storages/azure/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("ordering", ordering) + .AddRequiredParameter("project", project.ToString()!) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -97,113 +121,272 @@ partial void ProcessListResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareListRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - ordering: ordering, - project: project); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareListRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + ordering: ordering, + project: project); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessListResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/storages/azure/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/storages/azure/\"", + 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); - ProcessListResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/storages/azure/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessListResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/storages/azure/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/storages/azure/\"", + 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); + ProcessListResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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 + (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageAzureClient.List2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureClient.List2.g.cs index ab7cc24..1309882 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureClient.List2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureClient.List2.g.cs @@ -14,6 +14,7 @@ public partial class StorageAzureClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -48,11 +49,13 @@ partial void ProcessList2ResponseContent( /// /// /// + /// 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> List2Async( int project, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -68,26 +71,47 @@ partial void ProcessList2ResponseContent( securityRequirements: s_List2SecurityRequirements, operationName: "List2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/storages/export/azure", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("ordering", ordering) - .AddRequiredParameter("project", project.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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/storages/export/azure", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("ordering", ordering) + .AddRequiredParameter("project", project.ToString()!) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -97,113 +121,272 @@ partial void ProcessList2ResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareList2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - ordering: ordering, - project: project); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareList2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + ordering: ordering, + project: project); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessList2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/storages/export/azure\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/storages/export/azure\"", + 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); - ProcessList2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/storages/export/azure\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessList2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/storages/export/azure\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/storages/export/azure\"", + 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); + ProcessList2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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 + (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageAzureClient.Sync.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureClient.Sync.g.cs index 1f5d51f..4e33798 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureClient.Sync.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureClient.Sync.g.cs @@ -14,6 +14,7 @@ public partial class StorageAzureClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,10 +46,12 @@ partial void ProcessSyncResponseContent( /// Sync tasks from an Azure import storage connection. /// /// + /// 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 SyncAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -63,22 +66,43 @@ partial void ProcessSyncResponseContent( securityRequirements: s_SyncSecurityRequirements, operationName: "SyncAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/azure/{id}/sync", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/azure/{id}/sync", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -88,112 +112,271 @@ partial void ProcessSyncResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareSyncRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareSyncRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessSyncResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync", + methodName: "SyncAsync", + pathTemplate: "$\"/api/storages/azure/{id}/sync\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync", + methodName: "SyncAsync", + pathTemplate: "$\"/api/storages/azure/{id}/sync\"", + 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); - ProcessSyncResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync", + methodName: "SyncAsync", + pathTemplate: "$\"/api/storages/azure/{id}/sync\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.AzureBlobImportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.AzureBlobImportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessSyncResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync", + methodName: "SyncAsync", + pathTemplate: "$\"/api/storages/azure/{id}/sync\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync", + methodName: "SyncAsync", + pathTemplate: "$\"/api/storages/azure/{id}/sync\"", + 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); + ProcessSyncResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.AzureBlobImportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.AzureBlobImportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageAzureClient.Sync2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureClient.Sync2.g.cs index 03eda3e..500875f 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureClient.Sync2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureClient.Sync2.g.cs @@ -14,6 +14,7 @@ public partial class StorageAzureClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,10 +46,12 @@ partial void ProcessSync2ResponseContent( /// Sync tasks from an Azure export storage connection. /// /// + /// 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 Sync2Async( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -63,22 +66,43 @@ partial void ProcessSync2ResponseContent( securityRequirements: s_Sync2SecurityRequirements, operationName: "Sync2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/export/azure/{id}/sync", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/export/azure/{id}/sync", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -88,112 +112,271 @@ partial void ProcessSync2ResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareSync2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareSync2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessSync2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync2", + methodName: "Sync2Async", + pathTemplate: "$\"/api/storages/export/azure/{id}/sync\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync2", + methodName: "Sync2Async", + pathTemplate: "$\"/api/storages/export/azure/{id}/sync\"", + 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); - ProcessSync2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync2", + methodName: "Sync2Async", + pathTemplate: "$\"/api/storages/export/azure/{id}/sync\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.AzureBlobExportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.AzureBlobExportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessSync2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync2", + methodName: "Sync2Async", + pathTemplate: "$\"/api/storages/export/azure/{id}/sync\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync2", + methodName: "Sync2Async", + pathTemplate: "$\"/api/storages/export/azure/{id}/sync\"", + 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); + ProcessSync2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.AzureBlobExportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.AzureBlobExportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageAzureClient.Update.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureClient.Update.g.cs index 7288e25..99fa024 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureClient.Update.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureClient.Update.g.cs @@ -14,6 +14,7 @@ public partial class StorageAzureClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -48,12 +49,14 @@ partial void ProcessUpdateResponseContent( /// /// /// + /// 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 UpdateAsync( int id, global::LabelStudio.ApiStoragesAzurePartialUpdateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -71,22 +74,43 @@ partial void ProcessUpdateResponseContent( securityRequirements: s_UpdateSecurityRequirements, operationName: "UpdateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/azure/{id}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/azure/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -96,119 +120,278 @@ partial void ProcessUpdateResponseContent( __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); - PrepareUpdateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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::LabelStudio.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); + PrepareUpdateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessUpdateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/storages/azure/{id}\"", + 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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/storages/azure/{id}\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessUpdateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/storages/azure/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.AzureBlobImportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.AzureBlobImportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessUpdateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/storages/azure/{id}\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/storages/azure/{id}\"", + httpMethod: "PATCH", + 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); + ProcessUpdateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.AzureBlobImportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.AzureBlobImportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 import storage
@@ -251,6 +434,7 @@ partial void ProcessUpdateResponseContent( /// Interpret objects as BLOBs and generate URLs. For example, if your bucket contains images, you can use this option to generate URLs for these images. If set to False, it will read the content of the file and load it into Label Studio.
/// 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 UpdateAsync( @@ -266,6 +450,7 @@ partial void ProcessUpdateResponseContent( string? regexFilter = default, string? title = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.ApiStoragesAzurePartialUpdateRequest @@ -286,6 +471,7 @@ partial void ProcessUpdateResponseContent( return await UpdateAsync( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureClient.Update2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureClient.Update2.g.cs index cf6d85c..1e6d93f 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureClient.Update2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureClient.Update2.g.cs @@ -14,6 +14,7 @@ public partial class StorageAzureClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -48,12 +49,14 @@ partial void ProcessUpdate2ResponseContent( ///
/// /// + /// 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 Update2Async( int id, global::LabelStudio.ApiStoragesExportAzurePartialUpdateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -71,22 +74,43 @@ partial void ProcessUpdate2ResponseContent( securityRequirements: s_Update2SecurityRequirements, operationName: "Update2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/export/azure/{id}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/export/azure/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -96,119 +120,278 @@ partial void ProcessUpdate2ResponseContent( __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); - PrepareUpdate2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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::LabelStudio.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); + PrepareUpdate2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessUpdate2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/storages/export/azure/{id}\"", + 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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/storages/export/azure/{id}\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessUpdate2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/storages/export/azure/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.AzureBlobExportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.AzureBlobExportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessUpdate2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/storages/export/azure/{id}\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/storages/export/azure/{id}\"", + httpMethod: "PATCH", + 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); + ProcessUpdate2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.AzureBlobExportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.AzureBlobExportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 export storage
@@ -240,6 +423,7 @@ partial void ProcessUpdate2ResponseContent( /// /// Storage title /// + /// 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 Update2Async( @@ -252,6 +436,7 @@ partial void ProcessUpdate2ResponseContent( string? prefix = default, int? project = default, string? title = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.ApiStoragesExportAzurePartialUpdateRequest @@ -269,6 +454,7 @@ partial void ProcessUpdate2ResponseContent( return await Update2Async( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureClient.Validate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureClient.Validate.g.cs index 4c084da..5262d08 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureClient.Validate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureClient.Validate.g.cs @@ -14,6 +14,7 @@ public partial class StorageAzureClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -40,11 +41,13 @@ partial void ProcessValidateResponse( /// Validate a specific Azure import storage connection. ///
/// + /// 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 ValidateAsync( global::LabelStudio.ApiStoragesAzureValidateCreateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -61,22 +64,43 @@ partial void ProcessValidateResponse( securityRequirements: s_ValidateSecurityRequirements, operationName: "ValidateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/storages/azure/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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/storages/azure/validate", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -86,102 +110,261 @@ partial void ProcessValidateResponse( __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::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareValidateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - request: request); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareValidateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate", + methodName: "ValidateAsync", + pathTemplate: "\"/api/storages/azure/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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate", + methodName: "ValidateAsync", + pathTemplate: "\"/api/storages/azure/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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessValidateResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate", + methodName: "ValidateAsync", + pathTemplate: "\"/api/storages/azure/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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessValidateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate", + methodName: "ValidateAsync", + pathTemplate: "\"/api/storages/azure/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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate", + methodName: "ValidateAsync", + pathTemplate: "\"/api/storages/azure/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); + } + + 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 import storage
@@ -226,6 +409,7 @@ partial void ProcessValidateResponse( /// Interpret objects as BLOBs and generate URLs. For example, if your bucket contains images, you can use this option to generate URLs for these images. If set to False, it will read the content of the file and load it into Label Studio.
/// 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 ValidateAsync( @@ -241,6 +425,7 @@ partial void ProcessValidateResponse( string? regexFilter = default, string? title = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.ApiStoragesAzureValidateCreateRequest @@ -261,6 +446,7 @@ partial void ProcessValidateResponse( await ValidateAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureClient.Validate2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureClient.Validate2.g.cs index 37df8e4..5a0ba54 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureClient.Validate2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureClient.Validate2.g.cs @@ -14,6 +14,7 @@ public partial class StorageAzureClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -40,11 +41,13 @@ partial void ProcessValidate2Response( /// Validate a specific Azure export storage connection. ///
/// + /// 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 Validate2Async( global::LabelStudio.ApiStoragesExportAzureValidateCreateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -61,22 +64,43 @@ partial void ProcessValidate2Response( securityRequirements: s_Validate2SecurityRequirements, operationName: "Validate2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/storages/export/azure/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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/storages/export/azure/validate", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -86,102 +110,261 @@ partial void ProcessValidate2Response( __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); - PrepareValidate2Request( - 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::LabelStudio.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); + PrepareValidate2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessValidate2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate2", + methodName: "Validate2Async", + pathTemplate: "\"/api/storages/export/azure/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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate2", + methodName: "Validate2Async", + pathTemplate: "\"/api/storages/export/azure/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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate2", + methodName: "Validate2Async", + pathTemplate: "\"/api/storages/export/azure/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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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) + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessValidate2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate2", + methodName: "Validate2Async", + pathTemplate: "\"/api/storages/export/azure/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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate2", + methodName: "Validate2Async", + pathTemplate: "\"/api/storages/export/azure/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); + } + + 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 export storage
@@ -215,6 +398,7 @@ partial void ProcessValidate2Response( /// /// Storage title /// + /// 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 Validate2Async( @@ -227,6 +411,7 @@ partial void ProcessValidate2Response( string? prefix = default, int? project = default, string? title = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.ApiStoragesExportAzureValidateCreateRequest @@ -244,6 +429,7 @@ partial void ProcessValidate2Response( await Validate2Async( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureClient.g.cs index 26c3350..8dce7f4 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureClient.g.cs @@ -30,6 +30,9 @@ public sealed partial class StorageAzureClient : global::LabelStudio.IStorageAzu #if DEBUG = true; #endif + + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public StorageAzureClient( 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 StorageAzureClient. + /// 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 StorageAzureClient( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::LabelStudio.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::LabelStudio.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureSpiClient.Create.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureSpiClient.Create.g.cs index 9d129f3..925d184 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureSpiClient.Create.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureSpiClient.Create.g.cs @@ -14,6 +14,7 @@ public partial class StorageAzureSpiClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,11 +52,13 @@ partial void ProcessCreateResponseContent( /// Create Azure import storage with Service Principal authentication. ///
/// + /// 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 CreateAsync( global::LabelStudio.AzureServicePrincipalImportStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -72,22 +75,43 @@ partial void ProcessCreateResponseContent( securityRequirements: s_CreateSecurityRequirements, operationName: "CreateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/storages/azure_spi/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/storages/azure_spi/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -97,118 +121,277 @@ partial void ProcessCreateResponseContent( __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::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCreateRequest( - 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); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/storages/azure_spi/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/storages/azure_spi/\"", + 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); - ProcessCreateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/storages/azure_spi/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.AzureServicePrincipalImportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.AzureServicePrincipalImportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessCreateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/storages/azure_spi/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/storages/azure_spi/\"", + 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); + ProcessCreateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.AzureServicePrincipalImportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.AzureServicePrincipalImportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 Azure import storage with SPI
@@ -291,6 +474,7 @@ partial void ProcessCreateResponseContent( /// /// User Delegation Key (Backend) /// + /// 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 CreateAsync( @@ -316,6 +500,7 @@ partial void ProcessCreateResponseContent( string? traceback = default, bool? useBlobUrls = default, string? userDelegationKey = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.AzureServicePrincipalImportStorageRequest @@ -346,6 +531,7 @@ partial void ProcessCreateResponseContent( return await CreateAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureSpiClient.Create2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureSpiClient.Create2.g.cs index 8d20d97..8234f28 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureSpiClient.Create2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureSpiClient.Create2.g.cs @@ -14,6 +14,7 @@ public partial class StorageAzureSpiClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,11 +52,13 @@ partial void ProcessCreate2ResponseContent( /// Create an Azure export storage connection with Service Principal authentication to store annotations. ///
/// + /// 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 Create2Async( global::LabelStudio.AzureServicePrincipalExportStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -72,22 +75,43 @@ partial void ProcessCreate2ResponseContent( securityRequirements: s_Create2SecurityRequirements, operationName: "Create2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/storages/export/azure_spi", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/storages/export/azure_spi", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -97,118 +121,277 @@ partial void ProcessCreate2ResponseContent( __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::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCreate2Request( - 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); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreate2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreate2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "\"/api/storages/export/azure_spi\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "\"/api/storages/export/azure_spi\"", + 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); - ProcessCreate2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "\"/api/storages/export/azure_spi\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.AzureServicePrincipalExportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.AzureServicePrincipalExportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessCreate2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "\"/api/storages/export/azure_spi\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "\"/api/storages/export/azure_spi\"", + 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); + ProcessCreate2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.AzureServicePrincipalExportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.AzureServicePrincipalExportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 Azure export storage with SPI authentication
@@ -285,6 +468,7 @@ partial void ProcessCreate2ResponseContent( /// /// User Delegation Key (Backend) /// + /// 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 Create2Async( @@ -308,6 +492,7 @@ partial void ProcessCreate2ResponseContent( string? traceback = default, bool? useBlobUrls = default, string? userDelegationKey = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.AzureServicePrincipalExportStorageRequest @@ -336,6 +521,7 @@ partial void ProcessCreate2ResponseContent( return await Create2Async( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureSpiClient.Delete.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureSpiClient.Delete.g.cs index d7244c7..1c8b453 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureSpiClient.Delete.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureSpiClient.Delete.g.cs @@ -14,6 +14,7 @@ public partial class StorageAzureSpiClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -46,10 +47,12 @@ partial void ProcessDeleteResponse( /// Delete a specific Azure import storage connection that was set up with Service Principal authentication. ///
/// + /// 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 DeleteAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -64,22 +67,43 @@ partial void ProcessDeleteResponse( securityRequirements: s_DeleteSecurityRequirements, operationName: "DeleteAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/azure_spi/{id}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/azure_spi/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -89,96 +113,255 @@ partial void ProcessDeleteResponse( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDeleteRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDeleteRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/storages/azure_spi/{id}\"", + 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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/storages/azure_spi/{id}\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessDeleteResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/storages/azure_spi/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessDeleteResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/storages/azure_spi/{id}\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/storages/azure_spi/{id}\"", + httpMethod: "DELETE", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageAzureSpiClient.Delete2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureSpiClient.Delete2.g.cs index 356bb82..b88f763 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureSpiClient.Delete2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureSpiClient.Delete2.g.cs @@ -14,6 +14,7 @@ public partial class StorageAzureSpiClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -46,10 +47,12 @@ partial void ProcessDelete2Response( /// Delete a specific Azure export storage connection that was set up with Service Principal authentication. /// /// + /// 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 Delete2Async( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -64,22 +67,43 @@ partial void ProcessDelete2Response( securityRequirements: s_Delete2SecurityRequirements, operationName: "Delete2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/export/azure_spi/{id}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/export/azure_spi/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -89,96 +113,255 @@ partial void ProcessDelete2Response( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDelete2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDelete2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/storages/export/azure_spi/{id}\"", + 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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/storages/export/azure_spi/{id}\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessDelete2Response( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/storages/export/azure_spi/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessDelete2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/storages/export/azure_spi/{id}\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/storages/export/azure_spi/{id}\"", + httpMethod: "DELETE", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageAzureSpiClient.Get.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureSpiClient.Get.g.cs index b8aeb4c..06dce39 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureSpiClient.Get.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureSpiClient.Get.g.cs @@ -14,6 +14,7 @@ public partial class StorageAzureSpiClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,10 +52,12 @@ partial void ProcessGetResponseContent( /// Get a specific Azure import storage connection that was set up with Service Principal authentication. /// /// + /// 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 GetAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -69,22 +72,43 @@ partial void ProcessGetResponseContent( securityRequirements: s_GetSecurityRequirements, operationName: "GetAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/azure_spi/{id}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/azure_spi/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,112 +118,271 @@ partial void ProcessGetResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/storages/azure_spi/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/storages/azure_spi/{id}\"", + 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); - ProcessGetResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/storages/azure_spi/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.AzureServicePrincipalImportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.AzureServicePrincipalImportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGetResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/storages/azure_spi/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/storages/azure_spi/{id}\"", + 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); + ProcessGetResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.AzureServicePrincipalImportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.AzureServicePrincipalImportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageAzureSpiClient.Get2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureSpiClient.Get2.g.cs index 41b80b3..852d2da 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureSpiClient.Get2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureSpiClient.Get2.g.cs @@ -14,6 +14,7 @@ public partial class StorageAzureSpiClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,10 +52,12 @@ partial void ProcessGet2ResponseContent( /// Get a specific Azure export storage connection that was set up with Service Principal authentication. /// /// + /// 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 Get2Async( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -69,22 +72,43 @@ partial void ProcessGet2ResponseContent( securityRequirements: s_Get2SecurityRequirements, operationName: "Get2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/export/azure_spi/{id}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/export/azure_spi/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,112 +118,271 @@ partial void ProcessGet2ResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGet2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGet2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGet2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "$\"/api/storages/export/azure_spi/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "$\"/api/storages/export/azure_spi/{id}\"", + 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); - ProcessGet2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "$\"/api/storages/export/azure_spi/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.AzureServicePrincipalExportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.AzureServicePrincipalExportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGet2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "$\"/api/storages/export/azure_spi/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "$\"/api/storages/export/azure_spi/{id}\"", + 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); + ProcessGet2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.AzureServicePrincipalExportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.AzureServicePrincipalExportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageAzureSpiClient.List.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureSpiClient.List.g.cs index 9a1c769..4131407 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureSpiClient.List.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureSpiClient.List.g.cs @@ -14,6 +14,7 @@ public partial class StorageAzureSpiClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -54,11 +55,13 @@ partial void ProcessListResponseContent( /// /// /// + /// 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> ListAsync( int project, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -74,26 +77,47 @@ partial void ProcessListResponseContent( securityRequirements: s_ListSecurityRequirements, operationName: "ListAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/storages/azure_spi/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("ordering", ordering) - .AddRequiredParameter("project", project.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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/storages/azure_spi/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("ordering", ordering) + .AddRequiredParameter("project", project.ToString()!) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -103,113 +127,272 @@ partial void ProcessListResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareListRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - ordering: ordering, - project: project); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareListRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + ordering: ordering, + project: project); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessListResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/storages/azure_spi/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/storages/azure_spi/\"", + 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); - ProcessListResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/storages/azure_spi/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessListResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/storages/azure_spi/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/storages/azure_spi/\"", + 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); + ProcessListResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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 + (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageAzureSpiClient.List2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureSpiClient.List2.g.cs index a8ec8b5..f779768 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureSpiClient.List2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureSpiClient.List2.g.cs @@ -14,6 +14,7 @@ public partial class StorageAzureSpiClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -54,11 +55,13 @@ partial void ProcessList2ResponseContent( /// /// /// + /// 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> List2Async( int project, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -74,26 +77,47 @@ partial void ProcessList2ResponseContent( securityRequirements: s_List2SecurityRequirements, operationName: "List2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/storages/export/azure_spi", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("ordering", ordering) - .AddRequiredParameter("project", project.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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/storages/export/azure_spi", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("ordering", ordering) + .AddRequiredParameter("project", project.ToString()!) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -103,113 +127,272 @@ partial void ProcessList2ResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareList2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - ordering: ordering, - project: project); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareList2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + ordering: ordering, + project: project); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessList2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/storages/export/azure_spi\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/storages/export/azure_spi\"", + 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); - ProcessList2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/storages/export/azure_spi\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessList2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/storages/export/azure_spi\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/storages/export/azure_spi\"", + 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); + ProcessList2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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 + (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageAzureSpiClient.Sync.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureSpiClient.Sync.g.cs index b666a09..8cc8b72 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureSpiClient.Sync.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureSpiClient.Sync.g.cs @@ -14,6 +14,7 @@ public partial class StorageAzureSpiClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,10 +52,12 @@ partial void ProcessSyncResponseContent( /// Sync tasks from an Azure import storage connection that was set up with Service Principal authentication. /// /// + /// 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 SyncAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -69,22 +72,43 @@ partial void ProcessSyncResponseContent( securityRequirements: s_SyncSecurityRequirements, operationName: "SyncAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/azure_spi/{id}/sync", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/azure_spi/{id}/sync", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,112 +118,271 @@ partial void ProcessSyncResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareSyncRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareSyncRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessSyncResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync", + methodName: "SyncAsync", + pathTemplate: "$\"/api/storages/azure_spi/{id}/sync\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync", + methodName: "SyncAsync", + pathTemplate: "$\"/api/storages/azure_spi/{id}/sync\"", + 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); - ProcessSyncResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync", + methodName: "SyncAsync", + pathTemplate: "$\"/api/storages/azure_spi/{id}/sync\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.AzureServicePrincipalImportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.AzureServicePrincipalImportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessSyncResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync", + methodName: "SyncAsync", + pathTemplate: "$\"/api/storages/azure_spi/{id}/sync\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync", + methodName: "SyncAsync", + pathTemplate: "$\"/api/storages/azure_spi/{id}/sync\"", + 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); + ProcessSyncResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.AzureServicePrincipalImportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.AzureServicePrincipalImportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageAzureSpiClient.Sync2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureSpiClient.Sync2.g.cs index f201310..9cd280f 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureSpiClient.Sync2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureSpiClient.Sync2.g.cs @@ -14,6 +14,7 @@ public partial class StorageAzureSpiClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,10 +52,12 @@ partial void ProcessSync2ResponseContent( /// Sync tasks from an Azure SPI export 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 Sync2Async( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -69,22 +72,43 @@ partial void ProcessSync2ResponseContent( securityRequirements: s_Sync2SecurityRequirements, operationName: "Sync2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/export/azure_spi/{id}/sync", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/export/azure_spi/{id}/sync", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,112 +118,271 @@ partial void ProcessSync2ResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareSync2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareSync2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessSync2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync2", + methodName: "Sync2Async", + pathTemplate: "$\"/api/storages/export/azure_spi/{id}/sync\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync2", + methodName: "Sync2Async", + pathTemplate: "$\"/api/storages/export/azure_spi/{id}/sync\"", + 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); - ProcessSync2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync2", + methodName: "Sync2Async", + pathTemplate: "$\"/api/storages/export/azure_spi/{id}/sync\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.AzureServicePrincipalExportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.AzureServicePrincipalExportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessSync2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync2", + methodName: "Sync2Async", + pathTemplate: "$\"/api/storages/export/azure_spi/{id}/sync\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync2", + methodName: "Sync2Async", + pathTemplate: "$\"/api/storages/export/azure_spi/{id}/sync\"", + 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); + ProcessSync2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.AzureServicePrincipalExportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.AzureServicePrincipalExportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageAzureSpiClient.Update.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureSpiClient.Update.g.cs index 57514a4..dbb9bd3 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureSpiClient.Update.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureSpiClient.Update.g.cs @@ -14,6 +14,7 @@ public partial class StorageAzureSpiClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -54,12 +55,14 @@ partial void ProcessUpdateResponseContent( /// /// /// + /// 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 UpdateAsync( int id, global::LabelStudio.PatchedAzureServicePrincipalImportStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -77,22 +80,43 @@ partial void ProcessUpdateResponseContent( securityRequirements: s_UpdateSecurityRequirements, operationName: "UpdateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/azure_spi/{id}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/azure_spi/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -102,119 +126,278 @@ partial void ProcessUpdateResponseContent( __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); - PrepareUpdateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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::LabelStudio.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); + PrepareUpdateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessUpdateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/storages/azure_spi/{id}\"", + 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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/storages/azure_spi/{id}\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessUpdateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/storages/azure_spi/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.AzureServicePrincipalImportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.AzureServicePrincipalImportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessUpdateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/storages/azure_spi/{id}\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/storages/azure_spi/{id}\"", + httpMethod: "PATCH", + 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); + ProcessUpdateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.AzureServicePrincipalImportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.AzureServicePrincipalImportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 Azure SPI import storage
@@ -298,6 +481,7 @@ partial void ProcessUpdateResponseContent( /// /// User Delegation Key (Backend) /// + /// 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 UpdateAsync( @@ -324,6 +508,7 @@ partial void ProcessUpdateResponseContent( string? traceback = default, bool? useBlobUrls = default, string? userDelegationKey = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.PatchedAzureServicePrincipalImportStorageRequest @@ -355,6 +540,7 @@ partial void ProcessUpdateResponseContent( return await UpdateAsync( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureSpiClient.Update2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureSpiClient.Update2.g.cs index fb76b0e..9d2cc42 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureSpiClient.Update2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureSpiClient.Update2.g.cs @@ -14,6 +14,7 @@ public partial class StorageAzureSpiClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -54,12 +55,14 @@ partial void ProcessUpdate2ResponseContent( ///
/// /// + /// 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 Update2Async( int id, global::LabelStudio.PatchedAzureServicePrincipalExportStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -77,22 +80,43 @@ partial void ProcessUpdate2ResponseContent( securityRequirements: s_Update2SecurityRequirements, operationName: "Update2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/export/azure_spi/{id}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/export/azure_spi/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -102,119 +126,278 @@ partial void ProcessUpdate2ResponseContent( __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); - PrepareUpdate2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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::LabelStudio.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); + PrepareUpdate2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessUpdate2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/storages/export/azure_spi/{id}\"", + 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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/storages/export/azure_spi/{id}\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessUpdate2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/storages/export/azure_spi/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.AzureServicePrincipalExportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.AzureServicePrincipalExportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessUpdate2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/storages/export/azure_spi/{id}\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/storages/export/azure_spi/{id}\"", + httpMethod: "PATCH", + 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); + ProcessUpdate2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.AzureServicePrincipalExportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.AzureServicePrincipalExportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 Azure SPI export storage
@@ -292,6 +475,7 @@ partial void ProcessUpdate2ResponseContent( /// /// User Delegation Key (Backend) /// + /// 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 Update2Async( @@ -316,6 +500,7 @@ partial void ProcessUpdate2ResponseContent( string? traceback = default, bool? useBlobUrls = default, string? userDelegationKey = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.PatchedAzureServicePrincipalExportStorageRequest @@ -345,6 +530,7 @@ partial void ProcessUpdate2ResponseContent( return await Update2Async( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureSpiClient.Validate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureSpiClient.Validate.g.cs index 3a71f6f..37d792f 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureSpiClient.Validate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureSpiClient.Validate.g.cs @@ -14,6 +14,7 @@ public partial class StorageAzureSpiClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -46,11 +47,13 @@ partial void ProcessValidateResponse( /// Validate a specific Azure import storage connection that was set up with Service Principal authentication. ///
/// + /// 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 ValidateAsync( global::LabelStudio.AzureServicePrincipalImportStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -67,22 +70,43 @@ partial void ProcessValidateResponse( securityRequirements: s_ValidateSecurityRequirements, operationName: "ValidateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/storages/azure_spi/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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/storages/azure_spi/validate", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -92,102 +116,261 @@ partial void ProcessValidateResponse( __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::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareValidateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - request: request); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareValidateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate", + methodName: "ValidateAsync", + pathTemplate: "\"/api/storages/azure_spi/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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate", + methodName: "ValidateAsync", + pathTemplate: "\"/api/storages/azure_spi/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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessValidateResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate", + methodName: "ValidateAsync", + pathTemplate: "\"/api/storages/azure_spi/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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessValidateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate", + methodName: "ValidateAsync", + pathTemplate: "\"/api/storages/azure_spi/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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate", + methodName: "ValidateAsync", + pathTemplate: "\"/api/storages/azure_spi/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); + } + + 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 Azure SPI import storage
@@ -270,6 +453,7 @@ partial void ProcessValidateResponse( /// /// User Delegation Key (Backend) /// + /// 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 ValidateAsync( @@ -295,6 +479,7 @@ partial void ProcessValidateResponse( string? traceback = default, bool? useBlobUrls = default, string? userDelegationKey = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.AzureServicePrincipalImportStorageRequest @@ -325,6 +510,7 @@ partial void ProcessValidateResponse( await ValidateAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureSpiClient.Validate2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureSpiClient.Validate2.g.cs index cf1d626..a186133 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureSpiClient.Validate2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureSpiClient.Validate2.g.cs @@ -14,6 +14,7 @@ public partial class StorageAzureSpiClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -46,11 +47,13 @@ partial void ProcessValidate2Response( /// Validate a specific Azure export storage connection that was set up with Service Principal authentication. ///
/// + /// 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 Validate2Async( global::LabelStudio.AzureServicePrincipalExportStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -67,22 +70,43 @@ partial void ProcessValidate2Response( securityRequirements: s_Validate2SecurityRequirements, operationName: "Validate2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/storages/export/azure_spi/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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/storages/export/azure_spi/validate", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -92,102 +116,261 @@ partial void ProcessValidate2Response( __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::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareValidate2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - request: request); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareValidate2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate2", + methodName: "Validate2Async", + pathTemplate: "\"/api/storages/export/azure_spi/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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate2", + methodName: "Validate2Async", + pathTemplate: "\"/api/storages/export/azure_spi/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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessValidate2Response( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate2", + methodName: "Validate2Async", + pathTemplate: "\"/api/storages/export/azure_spi/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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessValidate2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate2", + methodName: "Validate2Async", + pathTemplate: "\"/api/storages/export/azure_spi/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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate2", + methodName: "Validate2Async", + pathTemplate: "\"/api/storages/export/azure_spi/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); + } + + 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 Azure SPI export storage
@@ -264,6 +447,7 @@ partial void ProcessValidate2Response( /// /// User Delegation Key (Backend) /// + /// 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 Validate2Async( @@ -287,6 +471,7 @@ partial void ProcessValidate2Response( string? traceback = default, bool? useBlobUrls = default, string? userDelegationKey = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.AzureServicePrincipalExportStorageRequest @@ -315,6 +500,7 @@ partial void ProcessValidate2Response( await Validate2Async( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureSpiClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureSpiClient.g.cs index 78098b9..f4d2a6b 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureSpiClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageAzureSpiClient.g.cs @@ -30,6 +30,9 @@ public sealed partial class StorageAzureSpiClient : global::LabelStudio.IStorage #if DEBUG = true; #endif + + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public StorageAzureSpiClient( 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 StorageAzureSpiClient. + /// 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 StorageAzureSpiClient( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::LabelStudio.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::LabelStudio.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StorageClient.ApiDatasetStoragesList.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageClient.ApiDatasetStoragesList.g.cs index 8518e78..1a9132c 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageClient.ApiDatasetStoragesList.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageClient.ApiDatasetStoragesList.g.cs @@ -14,6 +14,7 @@ public partial class StorageClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -40,10 +41,12 @@ partial void ProcessApiDatasetStoragesListResponse( /// Retrieve a list of the dataset storages of all types with their 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 ApiDatasetStoragesListAsync( string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -58,25 +61,46 @@ partial void ProcessApiDatasetStoragesListResponse( securityRequirements: s_ApiDatasetStoragesListSecurityRequirements, operationName: "ApiDatasetStoragesListAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/dataset-storages/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("ordering", ordering) - ; - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/dataset-storages/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("ordering", ordering) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -86,96 +110,255 @@ partial void ProcessApiDatasetStoragesListResponse( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareApiDatasetStoragesListRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - ordering: ordering); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareApiDatasetStoragesListRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + ordering: ordering); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesList", + methodName: "ApiDatasetStoragesListAsync", + pathTemplate: "\"/api/dataset-storages/\"", + 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: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesList", + methodName: "ApiDatasetStoragesListAsync", + pathTemplate: "\"/api/dataset-storages/\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiDatasetStoragesListResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesList", + methodName: "ApiDatasetStoragesListAsync", + pathTemplate: "\"/api/dataset-storages/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessApiDatasetStoragesListResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesList", + methodName: "ApiDatasetStoragesListAsync", + pathTemplate: "\"/api/dataset-storages/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesList", + methodName: "ApiDatasetStoragesListAsync", + pathTemplate: "\"/api/dataset-storages/\"", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageClient.ApiDatasetStoragesTypesRetrieve.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageClient.ApiDatasetStoragesTypesRetrieve.g.cs index e1d2505..e677ff7 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageClient.ApiDatasetStoragesTypesRetrieve.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageClient.ApiDatasetStoragesTypesRetrieve.g.cs @@ -14,6 +14,7 @@ public partial class StorageClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -37,9 +38,11 @@ partial void ProcessApiDatasetStoragesTypesRetrieveResponse( /// List all dataset storages types
/// Retrieve a list of the dataset storages types. /// + /// 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 ApiDatasetStoragesTypesRetrieveAsync( + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -53,22 +56,43 @@ partial void ProcessApiDatasetStoragesTypesRetrieveResponse( securityRequirements: s_ApiDatasetStoragesTypesRetrieveSecurityRequirements, operationName: "ApiDatasetStoragesTypesRetrieveAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/dataset-storages/types/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/dataset-storages/types/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -78,95 +102,254 @@ partial void ProcessApiDatasetStoragesTypesRetrieveResponse( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareApiDatasetStoragesTypesRetrieveRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareApiDatasetStoragesTypesRetrieveRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest); + + return __httpRequest; + } - using var __response = await HttpClient.SendAsync( + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesTypesRetrieve", + methodName: "ApiDatasetStoragesTypesRetrieveAsync", + pathTemplate: "\"/api/dataset-storages/types/\"", + 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: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesTypesRetrieve", + methodName: "ApiDatasetStoragesTypesRetrieveAsync", + pathTemplate: "\"/api/dataset-storages/types/\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiDatasetStoragesTypesRetrieveResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesTypesRetrieve", + methodName: "ApiDatasetStoragesTypesRetrieveAsync", + pathTemplate: "\"/api/dataset-storages/types/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessApiDatasetStoragesTypesRetrieveResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesTypesRetrieve", + methodName: "ApiDatasetStoragesTypesRetrieveAsync", + pathTemplate: "\"/api/dataset-storages/types/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiDatasetStoragesTypesRetrieve", + methodName: "ApiDatasetStoragesTypesRetrieveAsync", + pathTemplate: "\"/api/dataset-storages/types/\"", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageClient.List.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageClient.List.g.cs index a6780c6..cbe40a9 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageClient.List.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageClient.List.g.cs @@ -14,6 +14,7 @@ public partial class StorageClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,10 +46,12 @@ partial void ProcessListResponseContent( /// Retrieve a list of the import storages of all types with their 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> ListAsync( string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -63,25 +66,46 @@ partial void ProcessListResponseContent( securityRequirements: s_ListSecurityRequirements, operationName: "ListAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/storages/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("ordering", ordering) - ; - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/storages/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("ordering", ordering) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -91,112 +115,271 @@ partial void ProcessListResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareListRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - ordering: ordering); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareListRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + ordering: ordering); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessListResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/storages/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/storages/\"", + 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); - ProcessListResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/storages/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessListResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/storages/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/storages/\"", + 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); + ProcessListResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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 + (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageClient.List2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageClient.List2.g.cs index 9972033..e8abf6c 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageClient.List2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageClient.List2.g.cs @@ -14,6 +14,7 @@ public partial class StorageClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,10 +46,12 @@ partial void ProcessList2ResponseContent( /// Retrieve a list of the export storages of all types with their 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> List2Async( string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -63,25 +66,46 @@ partial void ProcessList2ResponseContent( securityRequirements: s_List2SecurityRequirements, operationName: "List2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/storages/export", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("ordering", ordering) - ; - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/storages/export", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("ordering", ordering) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -91,112 +115,271 @@ partial void ProcessList2ResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareList2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - ordering: ordering); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareList2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + ordering: ordering); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessList2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/storages/export\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/storages/export\"", + 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); - ProcessList2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/storages/export\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessList2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/storages/export\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/storages/export\"", + 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); + ProcessList2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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 + (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageClient.ListTypes.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageClient.ListTypes.g.cs index cf1e8e1..1206618 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageClient.ListTypes.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageClient.ListTypes.g.cs @@ -14,6 +14,7 @@ public partial class StorageClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -42,9 +43,11 @@ partial void ProcessListTypesResponseContent( /// List all export storages types
/// Retrieve a list of the export storages types. /// + /// 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> ListTypesAsync( + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -58,22 +61,43 @@ partial void ProcessListTypesResponseContent( securityRequirements: s_ListTypesSecurityRequirements, operationName: "ListTypesAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/storages/export/types", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/storages/export/types", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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 ProcessListTypesResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareListTypesRequest( - 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); + PrepareListTypesRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessListTypesResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListTypes", + methodName: "ListTypesAsync", + pathTemplate: "\"/api/storages/export/types\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListTypes", + methodName: "ListTypesAsync", + pathTemplate: "\"/api/storages/export/types\"", + 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); - ProcessListTypesResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListTypes", + methodName: "ListTypesAsync", + pathTemplate: "\"/api/storages/export/types\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessListTypesResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListTypes", + methodName: "ListTypesAsync", + pathTemplate: "\"/api/storages/export/types\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListTypes", + methodName: "ListTypesAsync", + pathTemplate: "\"/api/storages/export/types\"", + 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); + ProcessListTypesResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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 + (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageClient.ListTypes2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageClient.ListTypes2.g.cs index 498117d..49088b3 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageClient.ListTypes2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageClient.ListTypes2.g.cs @@ -14,6 +14,7 @@ public partial class StorageClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -42,9 +43,11 @@ partial void ProcessListTypes2ResponseContent( /// List all import storages types
/// Retrieve a list of the import storages types. /// + /// 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> ListTypes2Async( + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -58,22 +61,43 @@ partial void ProcessListTypes2ResponseContent( securityRequirements: s_ListTypes2SecurityRequirements, operationName: "ListTypes2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/storages/types", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/storages/types", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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 ProcessListTypes2ResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareListTypes2Request( - 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); + PrepareListTypes2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessListTypes2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListTypes2", + methodName: "ListTypes2Async", + pathTemplate: "\"/api/storages/types\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListTypes2", + methodName: "ListTypes2Async", + pathTemplate: "\"/api/storages/types\"", + 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); - ProcessListTypes2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListTypes2", + methodName: "ListTypes2Async", + pathTemplate: "\"/api/storages/types\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessListTypes2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListTypes2", + methodName: "ListTypes2Async", + pathTemplate: "\"/api/storages/types\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListTypes2", + methodName: "ListTypes2Async", + pathTemplate: "\"/api/storages/types\"", + 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); + ProcessListTypes2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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 + (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageClient.g.cs index efe9ef5..915645c 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageClient.g.cs @@ -30,6 +30,9 @@ public sealed partial class StorageClient : global::LabelStudio.IStorageClient, #if DEBUG = true; #endif + + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public StorageClient( 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 StorageClient. + /// 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 StorageClient( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::LabelStudio.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::LabelStudio.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StorageDatabricksFilesClient.Create.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageDatabricksFilesClient.Create.g.cs index 473c435..94be56a 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageDatabricksFilesClient.Create.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageDatabricksFilesClient.Create.g.cs @@ -14,6 +14,7 @@ public partial class StorageDatabricksFilesClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,11 +52,13 @@ partial void ProcessCreateResponseContent( /// Create a Databricks Files import storage connection. /// /// + /// 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 CreateAsync( global::LabelStudio.DatabricksImportStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -72,22 +75,43 @@ partial void ProcessCreateResponseContent( securityRequirements: s_CreateSecurityRequirements, operationName: "CreateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/storages/databricks/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/storages/databricks/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -97,118 +121,277 @@ partial void ProcessCreateResponseContent( __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::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCreateRequest( - 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); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/storages/databricks/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/storages/databricks/\"", + 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); - ProcessCreateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/storages/databricks/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.DatabricksImportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.DatabricksImportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessCreateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/storages/databricks/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/storages/databricks/\"", + 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); + ProcessCreateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.DatabricksImportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.DatabricksImportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 Databricks import storage
@@ -311,6 +494,7 @@ partial void ProcessCreateResponseContent( /// /// UC volume name /// + /// 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 CreateAsync( @@ -342,6 +526,7 @@ partial void ProcessCreateResponseContent( string? traceback = default, bool? useBlobUrls = default, bool? verifyTls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.DatabricksImportStorageRequest @@ -378,6 +563,7 @@ partial void ProcessCreateResponseContent( return await CreateAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StorageDatabricksFilesClient.Create2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageDatabricksFilesClient.Create2.g.cs index 52a90ed..2e5389a 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageDatabricksFilesClient.Create2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageDatabricksFilesClient.Create2.g.cs @@ -14,6 +14,7 @@ public partial class StorageDatabricksFilesClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,11 +52,13 @@ partial void ProcessCreate2ResponseContent( /// Create a Databricks Files export storage connection. ///
/// + /// 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 Create2Async( global::LabelStudio.DatabricksExportStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -72,22 +75,43 @@ partial void ProcessCreate2ResponseContent( securityRequirements: s_Create2SecurityRequirements, operationName: "Create2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/storages/export/databricks", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/storages/export/databricks", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -97,118 +121,277 @@ partial void ProcessCreate2ResponseContent( __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::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCreate2Request( - 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); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreate2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreate2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "\"/api/storages/export/databricks\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "\"/api/storages/export/databricks\"", + 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); - ProcessCreate2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "\"/api/storages/export/databricks\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.DatabricksExportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.DatabricksExportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessCreate2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "\"/api/storages/export/databricks\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "\"/api/storages/export/databricks\"", + 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); + ProcessCreate2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.DatabricksExportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.DatabricksExportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 Databricks export storage
@@ -305,6 +488,7 @@ partial void ProcessCreate2ResponseContent( /// /// UC volume name /// + /// 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 Create2Async( @@ -334,6 +518,7 @@ partial void ProcessCreate2ResponseContent( string? traceback = default, bool? useBlobUrls = default, bool? verifyTls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.DatabricksExportStorageRequest @@ -368,6 +553,7 @@ partial void ProcessCreate2ResponseContent( return await Create2Async( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StorageDatabricksFilesClient.Delete.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageDatabricksFilesClient.Delete.g.cs index 82ede21..c16bb72 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageDatabricksFilesClient.Delete.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageDatabricksFilesClient.Delete.g.cs @@ -14,6 +14,7 @@ public partial class StorageDatabricksFilesClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -46,10 +47,12 @@ partial void ProcessDeleteResponse( /// Delete a specific Databricks Files import storage connection. ///
/// + /// 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 DeleteAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -64,22 +67,43 @@ partial void ProcessDeleteResponse( securityRequirements: s_DeleteSecurityRequirements, operationName: "DeleteAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/databricks/{id}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/databricks/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -89,96 +113,255 @@ partial void ProcessDeleteResponse( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDeleteRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDeleteRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/storages/databricks/{id}\"", + 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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/storages/databricks/{id}\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessDeleteResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/storages/databricks/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessDeleteResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/storages/databricks/{id}\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/storages/databricks/{id}\"", + httpMethod: "DELETE", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageDatabricksFilesClient.Delete2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageDatabricksFilesClient.Delete2.g.cs index 67af847..3da86b0 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageDatabricksFilesClient.Delete2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageDatabricksFilesClient.Delete2.g.cs @@ -14,6 +14,7 @@ public partial class StorageDatabricksFilesClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -46,10 +47,12 @@ partial void ProcessDelete2Response( /// Delete a specific Databricks Files export storage connection. /// /// + /// 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 Delete2Async( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -64,22 +67,43 @@ partial void ProcessDelete2Response( securityRequirements: s_Delete2SecurityRequirements, operationName: "Delete2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/export/databricks/{id}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/export/databricks/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -89,96 +113,255 @@ partial void ProcessDelete2Response( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDelete2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDelete2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/storages/export/databricks/{id}\"", + 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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/storages/export/databricks/{id}\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessDelete2Response( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/storages/export/databricks/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessDelete2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/storages/export/databricks/{id}\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/storages/export/databricks/{id}\"", + httpMethod: "DELETE", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageDatabricksFilesClient.Get.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageDatabricksFilesClient.Get.g.cs index a9895a5..a477732 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageDatabricksFilesClient.Get.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageDatabricksFilesClient.Get.g.cs @@ -14,6 +14,7 @@ public partial class StorageDatabricksFilesClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,10 +52,12 @@ partial void ProcessGetResponseContent( /// Get a specific Databricks Files import storage connection. /// /// + /// 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 GetAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -69,22 +72,43 @@ partial void ProcessGetResponseContent( securityRequirements: s_GetSecurityRequirements, operationName: "GetAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/databricks/{id}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/databricks/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,112 +118,271 @@ partial void ProcessGetResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/storages/databricks/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/storages/databricks/{id}\"", + 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); - ProcessGetResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/storages/databricks/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.DatabricksImportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.DatabricksImportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGetResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/storages/databricks/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/storages/databricks/{id}\"", + 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); + ProcessGetResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.DatabricksImportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.DatabricksImportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageDatabricksFilesClient.Get2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageDatabricksFilesClient.Get2.g.cs index b1ec845..7007866 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageDatabricksFilesClient.Get2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageDatabricksFilesClient.Get2.g.cs @@ -14,6 +14,7 @@ public partial class StorageDatabricksFilesClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,10 +52,12 @@ partial void ProcessGet2ResponseContent( /// Get a specific Databricks Files export storage connection. /// /// + /// 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 Get2Async( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -69,22 +72,43 @@ partial void ProcessGet2ResponseContent( securityRequirements: s_Get2SecurityRequirements, operationName: "Get2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/export/databricks/{id}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/export/databricks/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,112 +118,271 @@ partial void ProcessGet2ResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGet2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGet2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGet2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "$\"/api/storages/export/databricks/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "$\"/api/storages/export/databricks/{id}\"", + 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); - ProcessGet2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "$\"/api/storages/export/databricks/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.DatabricksExportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.DatabricksExportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGet2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "$\"/api/storages/export/databricks/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "$\"/api/storages/export/databricks/{id}\"", + 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); + ProcessGet2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.DatabricksExportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.DatabricksExportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageDatabricksFilesClient.List.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageDatabricksFilesClient.List.g.cs index 696d040..ce691eb 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageDatabricksFilesClient.List.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageDatabricksFilesClient.List.g.cs @@ -14,6 +14,7 @@ public partial class StorageDatabricksFilesClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -54,11 +55,13 @@ partial void ProcessListResponseContent( /// /// /// + /// 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> ListAsync( int project, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -74,26 +77,47 @@ partial void ProcessListResponseContent( securityRequirements: s_ListSecurityRequirements, operationName: "ListAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/storages/databricks/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("ordering", ordering) - .AddRequiredParameter("project", project.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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/storages/databricks/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("ordering", ordering) + .AddRequiredParameter("project", project.ToString()!) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -103,113 +127,272 @@ partial void ProcessListResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareListRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - ordering: ordering, - project: project); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareListRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + ordering: ordering, + project: project); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessListResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/storages/databricks/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/storages/databricks/\"", + 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); - ProcessListResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/storages/databricks/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessListResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/storages/databricks/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/storages/databricks/\"", + 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); + ProcessListResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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 + (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageDatabricksFilesClient.List2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageDatabricksFilesClient.List2.g.cs index dd68b30..ada816c 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageDatabricksFilesClient.List2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageDatabricksFilesClient.List2.g.cs @@ -14,6 +14,7 @@ public partial class StorageDatabricksFilesClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -54,11 +55,13 @@ partial void ProcessList2ResponseContent( /// /// /// + /// 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> List2Async( int project, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -74,26 +77,47 @@ partial void ProcessList2ResponseContent( securityRequirements: s_List2SecurityRequirements, operationName: "List2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/storages/export/databricks", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("ordering", ordering) - .AddRequiredParameter("project", project.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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/storages/export/databricks", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("ordering", ordering) + .AddRequiredParameter("project", project.ToString()!) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -103,113 +127,272 @@ partial void ProcessList2ResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareList2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - ordering: ordering, - project: project); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareList2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + ordering: ordering, + project: project); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessList2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/storages/export/databricks\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/storages/export/databricks\"", + 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); - ProcessList2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/storages/export/databricks\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessList2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/storages/export/databricks\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/storages/export/databricks\"", + 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); + ProcessList2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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 + (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageDatabricksFilesClient.Sync.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageDatabricksFilesClient.Sync.g.cs index efc5b79..4782ae0 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageDatabricksFilesClient.Sync.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageDatabricksFilesClient.Sync.g.cs @@ -14,6 +14,7 @@ public partial class StorageDatabricksFilesClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,10 +52,12 @@ partial void ProcessSyncResponseContent( /// Sync tasks from a Databricks Files import 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 SyncAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -69,22 +72,43 @@ partial void ProcessSyncResponseContent( securityRequirements: s_SyncSecurityRequirements, operationName: "SyncAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/databricks/{id}/sync", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/databricks/{id}/sync", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,112 +118,271 @@ partial void ProcessSyncResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareSyncRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareSyncRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessSyncResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync", + methodName: "SyncAsync", + pathTemplate: "$\"/api/storages/databricks/{id}/sync\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync", + methodName: "SyncAsync", + pathTemplate: "$\"/api/storages/databricks/{id}/sync\"", + 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); - ProcessSyncResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync", + methodName: "SyncAsync", + pathTemplate: "$\"/api/storages/databricks/{id}/sync\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.DatabricksImportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.DatabricksImportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessSyncResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync", + methodName: "SyncAsync", + pathTemplate: "$\"/api/storages/databricks/{id}/sync\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync", + methodName: "SyncAsync", + pathTemplate: "$\"/api/storages/databricks/{id}/sync\"", + 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); + ProcessSyncResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.DatabricksImportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.DatabricksImportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageDatabricksFilesClient.Sync2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageDatabricksFilesClient.Sync2.g.cs index d3f0a41..d8606bc 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageDatabricksFilesClient.Sync2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageDatabricksFilesClient.Sync2.g.cs @@ -14,6 +14,7 @@ public partial class StorageDatabricksFilesClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,10 +52,12 @@ partial void ProcessSync2ResponseContent( /// Export annotations to a Databricks Files 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 Sync2Async( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -69,22 +72,43 @@ partial void ProcessSync2ResponseContent( securityRequirements: s_Sync2SecurityRequirements, operationName: "Sync2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/export/databricks/{id}/sync", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/export/databricks/{id}/sync", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,112 +118,271 @@ partial void ProcessSync2ResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareSync2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareSync2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessSync2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync2", + methodName: "Sync2Async", + pathTemplate: "$\"/api/storages/export/databricks/{id}/sync\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync2", + methodName: "Sync2Async", + pathTemplate: "$\"/api/storages/export/databricks/{id}/sync\"", + 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); - ProcessSync2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync2", + methodName: "Sync2Async", + pathTemplate: "$\"/api/storages/export/databricks/{id}/sync\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.DatabricksExportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.DatabricksExportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessSync2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync2", + methodName: "Sync2Async", + pathTemplate: "$\"/api/storages/export/databricks/{id}/sync\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync2", + methodName: "Sync2Async", + pathTemplate: "$\"/api/storages/export/databricks/{id}/sync\"", + 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); + ProcessSync2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.DatabricksExportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.DatabricksExportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageDatabricksFilesClient.Update.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageDatabricksFilesClient.Update.g.cs index f28adb6..52773a7 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageDatabricksFilesClient.Update.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageDatabricksFilesClient.Update.g.cs @@ -14,6 +14,7 @@ public partial class StorageDatabricksFilesClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -54,12 +55,14 @@ partial void ProcessUpdateResponseContent( /// /// /// + /// 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 UpdateAsync( int id, global::LabelStudio.PatchedDatabricksImportStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -77,22 +80,43 @@ partial void ProcessUpdateResponseContent( securityRequirements: s_UpdateSecurityRequirements, operationName: "UpdateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/databricks/{id}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/databricks/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -102,119 +126,278 @@ partial void ProcessUpdateResponseContent( __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); - PrepareUpdateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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::LabelStudio.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); + PrepareUpdateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessUpdateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/storages/databricks/{id}\"", + 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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/storages/databricks/{id}\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessUpdateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/storages/databricks/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.DatabricksImportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.DatabricksImportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessUpdateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/storages/databricks/{id}\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/storages/databricks/{id}\"", + httpMethod: "PATCH", + 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); + ProcessUpdateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.DatabricksImportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.DatabricksImportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 Databricks import storage
@@ -318,6 +501,7 @@ partial void ProcessUpdateResponseContent( /// /// UC volume name /// + /// 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 UpdateAsync( @@ -350,6 +534,7 @@ partial void ProcessUpdateResponseContent( bool? useBlobUrls = default, bool? verifyTls = default, string? volume = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.PatchedDatabricksImportStorageRequest @@ -387,6 +572,7 @@ partial void ProcessUpdateResponseContent( return await UpdateAsync( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StorageDatabricksFilesClient.Update2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageDatabricksFilesClient.Update2.g.cs index 038f0c0..a73c23f 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageDatabricksFilesClient.Update2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageDatabricksFilesClient.Update2.g.cs @@ -14,6 +14,7 @@ public partial class StorageDatabricksFilesClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -54,12 +55,14 @@ partial void ProcessUpdate2ResponseContent( ///
/// /// + /// 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 Update2Async( int id, global::LabelStudio.PatchedDatabricksExportStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -77,22 +80,43 @@ partial void ProcessUpdate2ResponseContent( securityRequirements: s_Update2SecurityRequirements, operationName: "Update2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/export/databricks/{id}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/export/databricks/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -102,119 +126,278 @@ partial void ProcessUpdate2ResponseContent( __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); - PrepareUpdate2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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::LabelStudio.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); + PrepareUpdate2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessUpdate2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/storages/export/databricks/{id}\"", + 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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/storages/export/databricks/{id}\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessUpdate2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/storages/export/databricks/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.DatabricksExportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.DatabricksExportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessUpdate2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/storages/export/databricks/{id}\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/storages/export/databricks/{id}\"", + httpMethod: "PATCH", + 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); + ProcessUpdate2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.DatabricksExportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.DatabricksExportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 Databricks export storage
@@ -312,6 +495,7 @@ partial void ProcessUpdate2ResponseContent( /// /// UC volume name /// + /// 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 Update2Async( @@ -342,6 +526,7 @@ partial void ProcessUpdate2ResponseContent( bool? useBlobUrls = default, bool? verifyTls = default, string? volume = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.PatchedDatabricksExportStorageRequest @@ -377,6 +562,7 @@ partial void ProcessUpdate2ResponseContent( return await Update2Async( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StorageDatabricksFilesClient.Validate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageDatabricksFilesClient.Validate.g.cs index e37c4f0..e765336 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageDatabricksFilesClient.Validate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageDatabricksFilesClient.Validate.g.cs @@ -14,6 +14,7 @@ public partial class StorageDatabricksFilesClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -46,11 +47,13 @@ partial void ProcessValidateResponse( /// Validate a specific Databricks Files import storage connection. ///
/// + /// 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 ValidateAsync( global::LabelStudio.DatabricksImportStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -67,22 +70,43 @@ partial void ProcessValidateResponse( securityRequirements: s_ValidateSecurityRequirements, operationName: "ValidateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/storages/databricks/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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/storages/databricks/validate", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -92,102 +116,261 @@ partial void ProcessValidateResponse( __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::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareValidateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - request: request); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareValidateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate", + methodName: "ValidateAsync", + pathTemplate: "\"/api/storages/databricks/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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate", + methodName: "ValidateAsync", + pathTemplate: "\"/api/storages/databricks/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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessValidateResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate", + methodName: "ValidateAsync", + pathTemplate: "\"/api/storages/databricks/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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessValidateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate", + methodName: "ValidateAsync", + pathTemplate: "\"/api/storages/databricks/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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate", + methodName: "ValidateAsync", + pathTemplate: "\"/api/storages/databricks/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); + } + + 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 Databricks import storage
@@ -290,6 +473,7 @@ partial void ProcessValidateResponse( /// /// UC volume name /// + /// 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 ValidateAsync( @@ -321,6 +505,7 @@ partial void ProcessValidateResponse( string? traceback = default, bool? useBlobUrls = default, bool? verifyTls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.DatabricksImportStorageRequest @@ -357,6 +542,7 @@ partial void ProcessValidateResponse( await ValidateAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StorageDatabricksFilesClient.Validate2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageDatabricksFilesClient.Validate2.g.cs index f914a3d..e216136 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageDatabricksFilesClient.Validate2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageDatabricksFilesClient.Validate2.g.cs @@ -14,6 +14,7 @@ public partial class StorageDatabricksFilesClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -46,11 +47,13 @@ partial void ProcessValidate2Response( /// Validate a specific Databricks Files export storage connection. ///
/// + /// 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 Validate2Async( global::LabelStudio.DatabricksExportStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -67,22 +70,43 @@ partial void ProcessValidate2Response( securityRequirements: s_Validate2SecurityRequirements, operationName: "Validate2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/storages/export/databricks/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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/storages/export/databricks/validate", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -92,102 +116,261 @@ partial void ProcessValidate2Response( __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::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareValidate2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - request: request); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareValidate2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate2", + methodName: "Validate2Async", + pathTemplate: "\"/api/storages/export/databricks/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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate2", + methodName: "Validate2Async", + pathTemplate: "\"/api/storages/export/databricks/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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessValidate2Response( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate2", + methodName: "Validate2Async", + pathTemplate: "\"/api/storages/export/databricks/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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessValidate2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate2", + methodName: "Validate2Async", + pathTemplate: "\"/api/storages/export/databricks/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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate2", + methodName: "Validate2Async", + pathTemplate: "\"/api/storages/export/databricks/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); + } + + 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 Databricks export storage
@@ -284,6 +467,7 @@ partial void ProcessValidate2Response( /// /// UC volume name /// + /// 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 Validate2Async( @@ -313,6 +497,7 @@ partial void ProcessValidate2Response( string? traceback = default, bool? useBlobUrls = default, bool? verifyTls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.DatabricksExportStorageRequest @@ -347,6 +532,7 @@ partial void ProcessValidate2Response( await Validate2Async( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StorageDatabricksFilesClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageDatabricksFilesClient.g.cs index 8e21b1c..637681b 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageDatabricksFilesClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageDatabricksFilesClient.g.cs @@ -30,6 +30,9 @@ public sealed partial class StorageDatabricksFilesClient : global::LabelStudio.I #if DEBUG = true; #endif + + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public StorageDatabricksFilesClient( 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 StorageDatabricksFilesClient. + /// 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 StorageDatabricksFilesClient( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::LabelStudio.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::LabelStudio.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsClient.Create.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsClient.Create.g.cs index 7503519..a80c838 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsClient.Create.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsClient.Create.g.cs @@ -14,6 +14,7 @@ public partial class StorageGcsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,11 +46,13 @@ partial void ProcessCreateResponseContent( /// Create a new GCS export storage connection to store annotations. ///
/// + /// 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 CreateAsync( global::LabelStudio.ApiStoragesExportGcsCreateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -66,22 +69,43 @@ partial void ProcessCreateResponseContent( securityRequirements: s_CreateSecurityRequirements, operationName: "CreateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/storages/export/gcs", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/storages/export/gcs", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,118 +115,277 @@ partial void ProcessCreateResponseContent( __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::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCreateRequest( - 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); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/storages/export/gcs\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/storages/export/gcs\"", + 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); - ProcessCreateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/storages/export/gcs\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.GCSExportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.GCSExportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessCreateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/storages/export/gcs\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/storages/export/gcs\"", + 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); + ProcessCreateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.GCSExportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.GCSExportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 export storage
@@ -233,6 +416,7 @@ partial void ProcessCreateResponseContent( /// /// Storage title /// + /// 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 CreateAsync( @@ -244,6 +428,7 @@ partial void ProcessCreateResponseContent( string? prefix = default, int? project = default, string? title = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.ApiStoragesExportGcsCreateRequest @@ -260,6 +445,7 @@ partial void ProcessCreateResponseContent( return await CreateAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsClient.Create2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsClient.Create2.g.cs index fc5e457..581391d 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsClient.Create2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsClient.Create2.g.cs @@ -14,6 +14,7 @@ public partial class StorageGcsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,11 +46,13 @@ partial void ProcessCreate2ResponseContent( /// Create a new GCS import storage connection. ///
/// + /// 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 Create2Async( global::LabelStudio.ApiStoragesGcsCreateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -66,22 +69,43 @@ partial void ProcessCreate2ResponseContent( securityRequirements: s_Create2SecurityRequirements, operationName: "Create2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/storages/gcs/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/storages/gcs/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,118 +115,277 @@ partial void ProcessCreate2ResponseContent( __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::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCreate2Request( - 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); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreate2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreate2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "\"/api/storages/gcs/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "\"/api/storages/gcs/\"", + 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); - ProcessCreate2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "\"/api/storages/gcs/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.GCSImportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.GCSImportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessCreate2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "\"/api/storages/gcs/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "\"/api/storages/gcs/\"", + 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); + ProcessCreate2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.GCSImportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.GCSImportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 import storage
@@ -244,6 +427,7 @@ partial void ProcessCreate2ResponseContent( /// Interpret objects as BLOBs and generate URLs. For example, if your bucket contains images, you can use this option to generate URLs for these images. If set to False, it will read the content of the file and load it into Label Studio.
/// 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 Create2Async( @@ -258,6 +442,7 @@ partial void ProcessCreate2ResponseContent( string? regexFilter = default, string? title = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.ApiStoragesGcsCreateRequest @@ -277,6 +462,7 @@ partial void ProcessCreate2ResponseContent( return await Create2Async( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsClient.Delete.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsClient.Delete.g.cs index 0f37edf..1fd46fb 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsClient.Delete.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsClient.Delete.g.cs @@ -14,6 +14,7 @@ public partial class StorageGcsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -40,10 +41,12 @@ partial void ProcessDeleteResponse( /// Delete a specific GCS export storage connection. ///
/// + /// 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 DeleteAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -58,22 +61,43 @@ partial void ProcessDeleteResponse( securityRequirements: s_DeleteSecurityRequirements, operationName: "DeleteAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/export/gcs/{id}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/export/gcs/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -83,96 +107,255 @@ partial void ProcessDeleteResponse( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDeleteRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDeleteRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/storages/export/gcs/{id}\"", + 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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/storages/export/gcs/{id}\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessDeleteResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/storages/export/gcs/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessDeleteResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/storages/export/gcs/{id}\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/storages/export/gcs/{id}\"", + httpMethod: "DELETE", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageGcsClient.Delete2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsClient.Delete2.g.cs index 5c2039c..b853e02 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsClient.Delete2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsClient.Delete2.g.cs @@ -14,6 +14,7 @@ public partial class StorageGcsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -40,10 +41,12 @@ partial void ProcessDelete2Response( /// Delete a specific GCS import storage connection. /// /// + /// 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 Delete2Async( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -58,22 +61,43 @@ partial void ProcessDelete2Response( securityRequirements: s_Delete2SecurityRequirements, operationName: "Delete2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/gcs/{id}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/gcs/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -83,96 +107,255 @@ partial void ProcessDelete2Response( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDelete2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDelete2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/storages/gcs/{id}\"", + 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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/storages/gcs/{id}\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessDelete2Response( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/storages/gcs/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessDelete2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/storages/gcs/{id}\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/storages/gcs/{id}\"", + httpMethod: "DELETE", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageGcsClient.Get.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsClient.Get.g.cs index 6ec7bda..d640c3e 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsClient.Get.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsClient.Get.g.cs @@ -14,6 +14,7 @@ public partial class StorageGcsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,10 +46,12 @@ partial void ProcessGetResponseContent( /// Get a specific GCS export storage connection. /// /// + /// 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 GetAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -63,22 +66,43 @@ partial void ProcessGetResponseContent( securityRequirements: s_GetSecurityRequirements, operationName: "GetAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/export/gcs/{id}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/export/gcs/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -88,112 +112,271 @@ partial void ProcessGetResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/storages/export/gcs/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/storages/export/gcs/{id}\"", + 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); - ProcessGetResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/storages/export/gcs/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.GCSExportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.GCSExportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGetResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/storages/export/gcs/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/storages/export/gcs/{id}\"", + 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); + ProcessGetResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.GCSExportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.GCSExportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageGcsClient.Get2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsClient.Get2.g.cs index 55fb21d..7238e7a 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsClient.Get2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsClient.Get2.g.cs @@ -14,6 +14,7 @@ public partial class StorageGcsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,10 +46,12 @@ partial void ProcessGet2ResponseContent( /// Get a specific GCS import storage connection. /// /// + /// 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 Get2Async( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -63,22 +66,43 @@ partial void ProcessGet2ResponseContent( securityRequirements: s_Get2SecurityRequirements, operationName: "Get2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/gcs/{id}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/gcs/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -88,112 +112,271 @@ partial void ProcessGet2ResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGet2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGet2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGet2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "$\"/api/storages/gcs/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "$\"/api/storages/gcs/{id}\"", + 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); - ProcessGet2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "$\"/api/storages/gcs/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.GCSImportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.GCSImportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGet2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "$\"/api/storages/gcs/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "$\"/api/storages/gcs/{id}\"", + 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); + ProcessGet2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.GCSImportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.GCSImportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageGcsClient.List.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsClient.List.g.cs index b894163..4bdde28 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsClient.List.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsClient.List.g.cs @@ -14,6 +14,7 @@ public partial class StorageGcsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -48,11 +49,13 @@ partial void ProcessListResponseContent( /// /// /// + /// 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> ListAsync( int project, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -68,26 +71,47 @@ partial void ProcessListResponseContent( securityRequirements: s_ListSecurityRequirements, operationName: "ListAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/storages/export/gcs", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("ordering", ordering) - .AddRequiredParameter("project", project.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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/storages/export/gcs", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("ordering", ordering) + .AddRequiredParameter("project", project.ToString()!) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -97,113 +121,272 @@ partial void ProcessListResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareListRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - ordering: ordering, - project: project); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareListRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + ordering: ordering, + project: project); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessListResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/storages/export/gcs\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/storages/export/gcs\"", + 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); - ProcessListResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/storages/export/gcs\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessListResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/storages/export/gcs\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/storages/export/gcs\"", + 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); + ProcessListResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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 + (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageGcsClient.List2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsClient.List2.g.cs index f451c5e..490d8cf 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsClient.List2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsClient.List2.g.cs @@ -14,6 +14,7 @@ public partial class StorageGcsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -48,11 +49,13 @@ partial void ProcessList2ResponseContent( /// /// /// + /// 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> List2Async( int project, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -68,26 +71,47 @@ partial void ProcessList2ResponseContent( securityRequirements: s_List2SecurityRequirements, operationName: "List2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/storages/gcs/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("ordering", ordering) - .AddRequiredParameter("project", project.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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/storages/gcs/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("ordering", ordering) + .AddRequiredParameter("project", project.ToString()!) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -97,113 +121,272 @@ partial void ProcessList2ResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareList2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - ordering: ordering, - project: project); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareList2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + ordering: ordering, + project: project); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessList2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/storages/gcs/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/storages/gcs/\"", + 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); - ProcessList2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/storages/gcs/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessList2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/storages/gcs/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/storages/gcs/\"", + 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); + ProcessList2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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 + (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageGcsClient.Sync.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsClient.Sync.g.cs index 6aa1434..b3b909f 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsClient.Sync.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsClient.Sync.g.cs @@ -14,6 +14,7 @@ public partial class StorageGcsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,10 +46,12 @@ partial void ProcessSyncResponseContent( /// Sync tasks from an GCS export storage connection. /// /// + /// 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 SyncAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -63,22 +66,43 @@ partial void ProcessSyncResponseContent( securityRequirements: s_SyncSecurityRequirements, operationName: "SyncAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/export/gcs/{id}/sync", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/export/gcs/{id}/sync", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -88,112 +112,271 @@ partial void ProcessSyncResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareSyncRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareSyncRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessSyncResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync", + methodName: "SyncAsync", + pathTemplate: "$\"/api/storages/export/gcs/{id}/sync\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync", + methodName: "SyncAsync", + pathTemplate: "$\"/api/storages/export/gcs/{id}/sync\"", + 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); - ProcessSyncResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync", + methodName: "SyncAsync", + pathTemplate: "$\"/api/storages/export/gcs/{id}/sync\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.GCSExportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.GCSExportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessSyncResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync", + methodName: "SyncAsync", + pathTemplate: "$\"/api/storages/export/gcs/{id}/sync\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync", + methodName: "SyncAsync", + pathTemplate: "$\"/api/storages/export/gcs/{id}/sync\"", + 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); + ProcessSyncResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.GCSExportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.GCSExportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageGcsClient.Sync2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsClient.Sync2.g.cs index dff369a..53b8bc4 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsClient.Sync2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsClient.Sync2.g.cs @@ -14,6 +14,7 @@ public partial class StorageGcsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,10 +46,12 @@ partial void ProcessSync2ResponseContent( /// Sync tasks from a GCS import storage connection. /// /// + /// 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 Sync2Async( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -63,22 +66,43 @@ partial void ProcessSync2ResponseContent( securityRequirements: s_Sync2SecurityRequirements, operationName: "Sync2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/gcs/{id}/sync", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/gcs/{id}/sync", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -88,112 +112,271 @@ partial void ProcessSync2ResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareSync2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareSync2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessSync2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync2", + methodName: "Sync2Async", + pathTemplate: "$\"/api/storages/gcs/{id}/sync\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync2", + methodName: "Sync2Async", + pathTemplate: "$\"/api/storages/gcs/{id}/sync\"", + 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); - ProcessSync2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync2", + methodName: "Sync2Async", + pathTemplate: "$\"/api/storages/gcs/{id}/sync\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.GCSImportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.GCSImportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessSync2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync2", + methodName: "Sync2Async", + pathTemplate: "$\"/api/storages/gcs/{id}/sync\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync2", + methodName: "Sync2Async", + pathTemplate: "$\"/api/storages/gcs/{id}/sync\"", + 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); + ProcessSync2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.GCSImportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.GCSImportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageGcsClient.Update.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsClient.Update.g.cs index 96bdbfb..e5ae426 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsClient.Update.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsClient.Update.g.cs @@ -14,6 +14,7 @@ public partial class StorageGcsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -48,12 +49,14 @@ partial void ProcessUpdateResponseContent( /// /// /// + /// 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 UpdateAsync( int id, global::LabelStudio.ApiStoragesExportGcsPartialUpdateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -71,22 +74,43 @@ partial void ProcessUpdateResponseContent( securityRequirements: s_UpdateSecurityRequirements, operationName: "UpdateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/export/gcs/{id}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/export/gcs/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -96,119 +120,278 @@ partial void ProcessUpdateResponseContent( __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); - PrepareUpdateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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::LabelStudio.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); + PrepareUpdateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessUpdateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/storages/export/gcs/{id}\"", + 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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/storages/export/gcs/{id}\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessUpdateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/storages/export/gcs/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.GCSExportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.GCSExportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessUpdateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/storages/export/gcs/{id}\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/storages/export/gcs/{id}\"", + httpMethod: "PATCH", + 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); + ProcessUpdateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.GCSExportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.GCSExportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 export storage
@@ -240,6 +423,7 @@ partial void ProcessUpdateResponseContent( /// /// Storage title /// + /// 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 UpdateAsync( @@ -252,6 +436,7 @@ partial void ProcessUpdateResponseContent( string? prefix = default, int? project = default, string? title = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.ApiStoragesExportGcsPartialUpdateRequest @@ -269,6 +454,7 @@ partial void ProcessUpdateResponseContent( return await UpdateAsync( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsClient.Update2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsClient.Update2.g.cs index 91572f3..94cb749 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsClient.Update2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsClient.Update2.g.cs @@ -14,6 +14,7 @@ public partial class StorageGcsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -48,12 +49,14 @@ partial void ProcessUpdate2ResponseContent( ///
/// /// + /// 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 Update2Async( int id, global::LabelStudio.ApiStoragesGcsPartialUpdateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -71,22 +74,43 @@ partial void ProcessUpdate2ResponseContent( securityRequirements: s_Update2SecurityRequirements, operationName: "Update2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/gcs/{id}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/gcs/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -96,119 +120,278 @@ partial void ProcessUpdate2ResponseContent( __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); - PrepareUpdate2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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::LabelStudio.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); + PrepareUpdate2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessUpdate2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/storages/gcs/{id}\"", + 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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/storages/gcs/{id}\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessUpdate2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/storages/gcs/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.GCSImportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.GCSImportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessUpdate2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/storages/gcs/{id}\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/storages/gcs/{id}\"", + httpMethod: "PATCH", + 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); + ProcessUpdate2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.GCSImportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.GCSImportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 import storage
@@ -251,6 +434,7 @@ partial void ProcessUpdate2ResponseContent( /// Interpret objects as BLOBs and generate URLs. For example, if your bucket contains images, you can use this option to generate URLs for these images. If set to False, it will read the content of the file and load it into Label Studio.
/// 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 Update2Async( @@ -266,6 +450,7 @@ partial void ProcessUpdate2ResponseContent( string? regexFilter = default, string? title = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.ApiStoragesGcsPartialUpdateRequest @@ -286,6 +471,7 @@ partial void ProcessUpdate2ResponseContent( return await Update2Async( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsClient.Validate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsClient.Validate.g.cs index b77fdf7..ecade8e 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsClient.Validate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsClient.Validate.g.cs @@ -14,6 +14,7 @@ public partial class StorageGcsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -40,11 +41,13 @@ partial void ProcessValidateResponse( /// Validate a specific GCS export storage connection. ///
/// + /// 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 ValidateAsync( global::LabelStudio.ApiStoragesExportGcsValidateCreateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -61,22 +64,43 @@ partial void ProcessValidateResponse( securityRequirements: s_ValidateSecurityRequirements, operationName: "ValidateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/storages/export/gcs/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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/storages/export/gcs/validate", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -86,102 +110,261 @@ partial void ProcessValidateResponse( __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); - PrepareValidateRequest( - 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::LabelStudio.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); + PrepareValidateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessValidateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate", + methodName: "ValidateAsync", + pathTemplate: "\"/api/storages/export/gcs/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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate", + methodName: "ValidateAsync", + pathTemplate: "\"/api/storages/export/gcs/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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate", + methodName: "ValidateAsync", + pathTemplate: "\"/api/storages/export/gcs/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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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) + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessValidateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate", + methodName: "ValidateAsync", + pathTemplate: "\"/api/storages/export/gcs/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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate", + methodName: "ValidateAsync", + pathTemplate: "\"/api/storages/export/gcs/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); + } + + 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 export storage
@@ -215,6 +398,7 @@ partial void ProcessValidateResponse( /// /// Storage title /// + /// 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 ValidateAsync( @@ -227,6 +411,7 @@ partial void ProcessValidateResponse( string? prefix = default, int? project = default, string? title = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.ApiStoragesExportGcsValidateCreateRequest @@ -244,6 +429,7 @@ partial void ProcessValidateResponse( await ValidateAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsClient.Validate2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsClient.Validate2.g.cs index b88f0de..5e42a56 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsClient.Validate2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsClient.Validate2.g.cs @@ -14,6 +14,7 @@ public partial class StorageGcsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -40,11 +41,13 @@ partial void ProcessValidate2Response( /// Validate a specific GCS import storage connection. ///
/// + /// 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 Validate2Async( global::LabelStudio.ApiStoragesGcsValidateCreateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -61,22 +64,43 @@ partial void ProcessValidate2Response( securityRequirements: s_Validate2SecurityRequirements, operationName: "Validate2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/storages/gcs/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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/storages/gcs/validate", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -86,102 +110,261 @@ partial void ProcessValidate2Response( __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::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareValidate2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - request: request); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareValidate2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate2", + methodName: "Validate2Async", + pathTemplate: "\"/api/storages/gcs/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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate2", + methodName: "Validate2Async", + pathTemplate: "\"/api/storages/gcs/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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessValidate2Response( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate2", + methodName: "Validate2Async", + pathTemplate: "\"/api/storages/gcs/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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessValidate2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate2", + methodName: "Validate2Async", + pathTemplate: "\"/api/storages/gcs/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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate2", + methodName: "Validate2Async", + pathTemplate: "\"/api/storages/gcs/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); + } + + 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 import storage
@@ -226,6 +409,7 @@ partial void ProcessValidate2Response( /// Interpret objects as BLOBs and generate URLs. For example, if your bucket contains images, you can use this option to generate URLs for these images. If set to False, it will read the content of the file and load it into Label Studio.
/// 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 Validate2Async( @@ -241,6 +425,7 @@ partial void ProcessValidate2Response( string? regexFilter = default, string? title = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.ApiStoragesGcsValidateCreateRequest @@ -261,6 +446,7 @@ partial void ProcessValidate2Response( await Validate2Async( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsClient.g.cs index afa140a..1f5a820 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsClient.g.cs @@ -30,6 +30,9 @@ public sealed partial class StorageGcsClient : global::LabelStudio.IStorageGcsCl #if DEBUG = true; #endif + + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public StorageGcsClient( 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 StorageGcsClient. + /// 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 StorageGcsClient( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::LabelStudio.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::LabelStudio.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsSaClient.Create.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsSaClient.Create.g.cs index 6755194..5bc3033 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsSaClient.Create.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsSaClient.Create.g.cs @@ -14,6 +14,7 @@ public partial class StorageGcsSaClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,11 +52,13 @@ partial void ProcessCreateResponseContent( /// Create a GCS export storage connection with SA Impersonation to store annotations. ///
/// + /// 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 CreateAsync( global::LabelStudio.GCSSAExportStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -72,22 +75,43 @@ partial void ProcessCreateResponseContent( securityRequirements: s_CreateSecurityRequirements, operationName: "CreateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/storages/export/gcs_sa", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/storages/export/gcs_sa", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -97,118 +121,277 @@ partial void ProcessCreateResponseContent( __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::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCreateRequest( - 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); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/storages/export/gcs_sa\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/storages/export/gcs_sa\"", + 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); - ProcessCreateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/storages/export/gcs_sa\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.GCSSAExportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.GCSSAExportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessCreateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/storages/export/gcs_sa\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/storages/export/gcs_sa\"", + 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); + ProcessCreateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.GCSSAExportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.GCSSAExportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 GCS export storage with SA Impersonation
@@ -276,6 +459,7 @@ partial void ProcessCreateResponseContent( /// /// Interpret objects as BLOBs and generate URLs /// + /// 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 CreateAsync( @@ -296,6 +480,7 @@ partial void ProcessCreateResponseContent( string? title = default, string? traceback = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.GCSSAExportStorageRequest @@ -321,6 +506,7 @@ partial void ProcessCreateResponseContent( return await CreateAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsSaClient.Create2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsSaClient.Create2.g.cs index 4ba51f6..eecf841 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsSaClient.Create2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsSaClient.Create2.g.cs @@ -14,6 +14,7 @@ public partial class StorageGcsSaClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,11 +52,13 @@ partial void ProcessCreate2ResponseContent( /// Create GCS import storage with Service Account Impersonation. ///
/// + /// 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 Create2Async( global::LabelStudio.GCSSAImportStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -72,22 +75,43 @@ partial void ProcessCreate2ResponseContent( securityRequirements: s_Create2SecurityRequirements, operationName: "Create2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/storages/gcs_sa/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/storages/gcs_sa/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -97,118 +121,277 @@ partial void ProcessCreate2ResponseContent( __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::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCreate2Request( - 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); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreate2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreate2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "\"/api/storages/gcs_sa/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "\"/api/storages/gcs_sa/\"", + 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); - ProcessCreate2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "\"/api/storages/gcs_sa/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.GCSSAImportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.GCSSAImportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessCreate2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "\"/api/storages/gcs_sa/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "\"/api/storages/gcs_sa/\"", + 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); + ProcessCreate2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.GCSSAImportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.GCSSAImportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 GCS import storage with SA Impersonation
@@ -282,6 +465,7 @@ partial void ProcessCreate2ResponseContent( /// /// Interpret objects as BLOBs and generate URLs /// + /// 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 Create2Async( @@ -304,6 +488,7 @@ partial void ProcessCreate2ResponseContent( string? title = default, string? traceback = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.GCSSAImportStorageRequest @@ -331,6 +516,7 @@ partial void ProcessCreate2ResponseContent( return await Create2Async( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsSaClient.Delete.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsSaClient.Delete.g.cs index c485b81..0d427f3 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsSaClient.Delete.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsSaClient.Delete.g.cs @@ -14,6 +14,7 @@ public partial class StorageGcsSaClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -46,10 +47,12 @@ partial void ProcessDeleteResponse( /// Delete a specific GCS export storage connection set up with SA Impersonation. ///
/// + /// 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 DeleteAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -64,22 +67,43 @@ partial void ProcessDeleteResponse( securityRequirements: s_DeleteSecurityRequirements, operationName: "DeleteAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/export/gcs_sa/{id}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/export/gcs_sa/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -89,96 +113,255 @@ partial void ProcessDeleteResponse( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDeleteRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDeleteRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/storages/export/gcs_sa/{id}\"", + 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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/storages/export/gcs_sa/{id}\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessDeleteResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/storages/export/gcs_sa/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessDeleteResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/storages/export/gcs_sa/{id}\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/storages/export/gcs_sa/{id}\"", + httpMethod: "DELETE", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageGcsSaClient.Delete2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsSaClient.Delete2.g.cs index e748a1c..44f50ed 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsSaClient.Delete2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsSaClient.Delete2.g.cs @@ -14,6 +14,7 @@ public partial class StorageGcsSaClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -46,10 +47,12 @@ partial void ProcessDelete2Response( /// Delete a specific GCS import storage connection set up with SA Impersonation. /// /// + /// 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 Delete2Async( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -64,22 +67,43 @@ partial void ProcessDelete2Response( securityRequirements: s_Delete2SecurityRequirements, operationName: "Delete2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/gcs_sa/{id}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/gcs_sa/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -89,96 +113,255 @@ partial void ProcessDelete2Response( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDelete2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDelete2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/storages/gcs_sa/{id}\"", + 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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/storages/gcs_sa/{id}\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessDelete2Response( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/storages/gcs_sa/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessDelete2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/storages/gcs_sa/{id}\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/storages/gcs_sa/{id}\"", + httpMethod: "DELETE", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageGcsSaClient.Get.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsSaClient.Get.g.cs index e57eb1d..17a8dba 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsSaClient.Get.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsSaClient.Get.g.cs @@ -14,6 +14,7 @@ public partial class StorageGcsSaClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,10 +52,12 @@ partial void ProcessGetResponseContent( /// Get a specific GCS export storage connection set up with SA Impersonation. /// /// + /// 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 GetAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -69,22 +72,43 @@ partial void ProcessGetResponseContent( securityRequirements: s_GetSecurityRequirements, operationName: "GetAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/export/gcs_sa/{id}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/export/gcs_sa/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,112 +118,271 @@ partial void ProcessGetResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/storages/export/gcs_sa/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/storages/export/gcs_sa/{id}\"", + 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); - ProcessGetResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/storages/export/gcs_sa/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.GCSSAExportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.GCSSAExportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGetResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/storages/export/gcs_sa/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/storages/export/gcs_sa/{id}\"", + 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); + ProcessGetResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.GCSSAExportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.GCSSAExportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageGcsSaClient.Get2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsSaClient.Get2.g.cs index b8d019c..ecbe8d6 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsSaClient.Get2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsSaClient.Get2.g.cs @@ -14,6 +14,7 @@ public partial class StorageGcsSaClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,10 +52,12 @@ partial void ProcessGet2ResponseContent( /// Get a specific GCS import storage connection set up with SA Impersonation. /// /// + /// 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 Get2Async( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -69,22 +72,43 @@ partial void ProcessGet2ResponseContent( securityRequirements: s_Get2SecurityRequirements, operationName: "Get2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/gcs_sa/{id}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/gcs_sa/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,112 +118,271 @@ partial void ProcessGet2ResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGet2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGet2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGet2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "$\"/api/storages/gcs_sa/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "$\"/api/storages/gcs_sa/{id}\"", + 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); - ProcessGet2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "$\"/api/storages/gcs_sa/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.GCSSAImportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.GCSSAImportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGet2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "$\"/api/storages/gcs_sa/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "$\"/api/storages/gcs_sa/{id}\"", + 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); + ProcessGet2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.GCSSAImportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.GCSSAImportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageGcsSaClient.List.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsSaClient.List.g.cs index 32b17d3..a16fed7 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsSaClient.List.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsSaClient.List.g.cs @@ -14,6 +14,7 @@ public partial class StorageGcsSaClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -54,11 +55,13 @@ partial void ProcessListResponseContent( /// /// /// + /// 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> ListAsync( int project, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -74,26 +77,47 @@ partial void ProcessListResponseContent( securityRequirements: s_ListSecurityRequirements, operationName: "ListAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/storages/export/gcs_sa", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("ordering", ordering) - .AddRequiredParameter("project", project.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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/storages/export/gcs_sa", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("ordering", ordering) + .AddRequiredParameter("project", project.ToString()!) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -103,113 +127,272 @@ partial void ProcessListResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareListRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - ordering: ordering, - project: project); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareListRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + ordering: ordering, + project: project); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessListResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/storages/export/gcs_sa\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/storages/export/gcs_sa\"", + 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); - ProcessListResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/storages/export/gcs_sa\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessListResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/storages/export/gcs_sa\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/storages/export/gcs_sa\"", + 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); + ProcessListResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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 + (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageGcsSaClient.List2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsSaClient.List2.g.cs index c23a770..7fd57e0 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsSaClient.List2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsSaClient.List2.g.cs @@ -14,6 +14,7 @@ public partial class StorageGcsSaClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -54,11 +55,13 @@ partial void ProcessList2ResponseContent( /// /// /// + /// 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> List2Async( int project, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -74,26 +77,47 @@ partial void ProcessList2ResponseContent( securityRequirements: s_List2SecurityRequirements, operationName: "List2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/storages/gcs_sa/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("ordering", ordering) - .AddRequiredParameter("project", project.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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/storages/gcs_sa/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("ordering", ordering) + .AddRequiredParameter("project", project.ToString()!) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -103,113 +127,272 @@ partial void ProcessList2ResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareList2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - ordering: ordering, - project: project); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareList2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + ordering: ordering, + project: project); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessList2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/storages/gcs_sa/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/storages/gcs_sa/\"", + 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); - ProcessList2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/storages/gcs_sa/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessList2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/storages/gcs_sa/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/storages/gcs_sa/\"", + 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); + ProcessList2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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 + (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageGcsSaClient.Sync.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsSaClient.Sync.g.cs index abb6e33..4bdb70a 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsSaClient.Sync.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsSaClient.Sync.g.cs @@ -14,6 +14,7 @@ public partial class StorageGcsSaClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,10 +52,12 @@ partial void ProcessSyncResponseContent( /// Sync annotations to a GCS SA export 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 SyncAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -69,22 +72,43 @@ partial void ProcessSyncResponseContent( securityRequirements: s_SyncSecurityRequirements, operationName: "SyncAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/export/gcs_sa/{id}/sync", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/export/gcs_sa/{id}/sync", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,112 +118,271 @@ partial void ProcessSyncResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareSyncRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareSyncRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessSyncResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync", + methodName: "SyncAsync", + pathTemplate: "$\"/api/storages/export/gcs_sa/{id}/sync\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync", + methodName: "SyncAsync", + pathTemplate: "$\"/api/storages/export/gcs_sa/{id}/sync\"", + 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); - ProcessSyncResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync", + methodName: "SyncAsync", + pathTemplate: "$\"/api/storages/export/gcs_sa/{id}/sync\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.GCSSAExportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.GCSSAExportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessSyncResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync", + methodName: "SyncAsync", + pathTemplate: "$\"/api/storages/export/gcs_sa/{id}/sync\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync", + methodName: "SyncAsync", + pathTemplate: "$\"/api/storages/export/gcs_sa/{id}/sync\"", + 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); + ProcessSyncResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.GCSSAExportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.GCSSAExportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageGcsSaClient.Sync2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsSaClient.Sync2.g.cs index 4e99d0e..e805156 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsSaClient.Sync2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsSaClient.Sync2.g.cs @@ -14,6 +14,7 @@ public partial class StorageGcsSaClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,10 +52,12 @@ partial void ProcessSync2ResponseContent( /// Sync tasks from a GCS import storage connection set up with SA Impersonation. /// /// + /// 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 Sync2Async( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -69,22 +72,43 @@ partial void ProcessSync2ResponseContent( securityRequirements: s_Sync2SecurityRequirements, operationName: "Sync2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/gcs_sa/{id}/sync", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/gcs_sa/{id}/sync", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,112 +118,271 @@ partial void ProcessSync2ResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareSync2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareSync2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessSync2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync2", + methodName: "Sync2Async", + pathTemplate: "$\"/api/storages/gcs_sa/{id}/sync\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync2", + methodName: "Sync2Async", + pathTemplate: "$\"/api/storages/gcs_sa/{id}/sync\"", + 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); - ProcessSync2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync2", + methodName: "Sync2Async", + pathTemplate: "$\"/api/storages/gcs_sa/{id}/sync\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.GCSSAImportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.GCSSAImportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessSync2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync2", + methodName: "Sync2Async", + pathTemplate: "$\"/api/storages/gcs_sa/{id}/sync\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync2", + methodName: "Sync2Async", + pathTemplate: "$\"/api/storages/gcs_sa/{id}/sync\"", + 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); + ProcessSync2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.GCSSAImportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.GCSSAImportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageGcsSaClient.Update.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsSaClient.Update.g.cs index 638488c..4dd2504 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsSaClient.Update.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsSaClient.Update.g.cs @@ -14,6 +14,7 @@ public partial class StorageGcsSaClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -54,12 +55,14 @@ partial void ProcessUpdateResponseContent( /// /// /// + /// 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 UpdateAsync( int id, global::LabelStudio.PatchedGCSSAExportStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -77,22 +80,43 @@ partial void ProcessUpdateResponseContent( securityRequirements: s_UpdateSecurityRequirements, operationName: "UpdateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/export/gcs_sa/{id}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/export/gcs_sa/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -102,119 +126,278 @@ partial void ProcessUpdateResponseContent( __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); - PrepareUpdateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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::LabelStudio.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); + PrepareUpdateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessUpdateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/storages/export/gcs_sa/{id}\"", + 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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/storages/export/gcs_sa/{id}\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessUpdateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/storages/export/gcs_sa/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.GCSSAExportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.GCSSAExportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessUpdateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/storages/export/gcs_sa/{id}\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/storages/export/gcs_sa/{id}\"", + httpMethod: "PATCH", + 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); + ProcessUpdateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.GCSSAExportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.GCSSAExportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 GCS SA export storage
@@ -283,6 +466,7 @@ partial void ProcessUpdateResponseContent( /// /// Interpret objects as BLOBs and generate URLs /// + /// 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 UpdateAsync( @@ -304,6 +488,7 @@ partial void ProcessUpdateResponseContent( string? title = default, string? traceback = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.PatchedGCSSAExportStorageRequest @@ -330,6 +515,7 @@ partial void ProcessUpdateResponseContent( return await UpdateAsync( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsSaClient.Update2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsSaClient.Update2.g.cs index 2cf206e..faedcb4 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsSaClient.Update2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsSaClient.Update2.g.cs @@ -14,6 +14,7 @@ public partial class StorageGcsSaClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -54,12 +55,14 @@ partial void ProcessUpdate2ResponseContent( ///
/// /// + /// 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 Update2Async( int id, global::LabelStudio.PatchedGCSSAImportStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -77,22 +80,43 @@ partial void ProcessUpdate2ResponseContent( securityRequirements: s_Update2SecurityRequirements, operationName: "Update2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/gcs_sa/{id}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/gcs_sa/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -102,119 +126,278 @@ partial void ProcessUpdate2ResponseContent( __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); - PrepareUpdate2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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::LabelStudio.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); + PrepareUpdate2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessUpdate2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/storages/gcs_sa/{id}\"", + 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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/storages/gcs_sa/{id}\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessUpdate2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/storages/gcs_sa/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.GCSSAImportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.GCSSAImportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessUpdate2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/storages/gcs_sa/{id}\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/storages/gcs_sa/{id}\"", + httpMethod: "PATCH", + 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); + ProcessUpdate2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.GCSSAImportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.GCSSAImportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 GCS SA import storage
@@ -289,6 +472,7 @@ partial void ProcessUpdate2ResponseContent( /// /// Interpret objects as BLOBs and generate URLs /// + /// 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 Update2Async( @@ -312,6 +496,7 @@ partial void ProcessUpdate2ResponseContent( string? title = default, string? traceback = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.PatchedGCSSAImportStorageRequest @@ -340,6 +525,7 @@ partial void ProcessUpdate2ResponseContent( return await Update2Async( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsSaClient.Validate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsSaClient.Validate.g.cs index 2a9c278..bc0e4b2 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsSaClient.Validate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsSaClient.Validate.g.cs @@ -14,6 +14,7 @@ public partial class StorageGcsSaClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -46,11 +47,13 @@ partial void ProcessValidateResponse( /// Validate a specific GCS export storage connection set up with SA Impersonation. ///
/// + /// 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 ValidateAsync( global::LabelStudio.GCSSAExportStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -67,22 +70,43 @@ partial void ProcessValidateResponse( securityRequirements: s_ValidateSecurityRequirements, operationName: "ValidateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/storages/export/gcs_sa/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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/storages/export/gcs_sa/validate", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -92,102 +116,261 @@ partial void ProcessValidateResponse( __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::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareValidateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - request: request); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareValidateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate", + methodName: "ValidateAsync", + pathTemplate: "\"/api/storages/export/gcs_sa/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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate", + methodName: "ValidateAsync", + pathTemplate: "\"/api/storages/export/gcs_sa/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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessValidateResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate", + methodName: "ValidateAsync", + pathTemplate: "\"/api/storages/export/gcs_sa/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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessValidateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate", + methodName: "ValidateAsync", + pathTemplate: "\"/api/storages/export/gcs_sa/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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate", + methodName: "ValidateAsync", + pathTemplate: "\"/api/storages/export/gcs_sa/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); + } + + 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 GCS SA export storage
@@ -255,6 +438,7 @@ partial void ProcessValidateResponse( /// /// Interpret objects as BLOBs and generate URLs /// + /// 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 ValidateAsync( @@ -275,6 +459,7 @@ partial void ProcessValidateResponse( string? title = default, string? traceback = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.GCSSAExportStorageRequest @@ -300,6 +485,7 @@ partial void ProcessValidateResponse( await ValidateAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsSaClient.Validate2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsSaClient.Validate2.g.cs index 19e2aa8..de329e2 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsSaClient.Validate2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsSaClient.Validate2.g.cs @@ -14,6 +14,7 @@ public partial class StorageGcsSaClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -46,11 +47,13 @@ partial void ProcessValidate2Response( /// Validate a specific GCS import storage connection set up with SA Impersonation. ///
/// + /// 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 Validate2Async( global::LabelStudio.GCSSAImportStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -67,22 +70,43 @@ partial void ProcessValidate2Response( securityRequirements: s_Validate2SecurityRequirements, operationName: "Validate2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/storages/gcs_sa/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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/storages/gcs_sa/validate", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -92,102 +116,261 @@ partial void ProcessValidate2Response( __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::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareValidate2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - request: request); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareValidate2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate2", + methodName: "Validate2Async", + pathTemplate: "\"/api/storages/gcs_sa/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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate2", + methodName: "Validate2Async", + pathTemplate: "\"/api/storages/gcs_sa/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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessValidate2Response( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate2", + methodName: "Validate2Async", + pathTemplate: "\"/api/storages/gcs_sa/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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessValidate2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate2", + methodName: "Validate2Async", + pathTemplate: "\"/api/storages/gcs_sa/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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate2", + methodName: "Validate2Async", + pathTemplate: "\"/api/storages/gcs_sa/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); + } + + 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 GCS SA import storage
@@ -261,6 +444,7 @@ partial void ProcessValidate2Response( /// /// Interpret objects as BLOBs and generate URLs /// + /// 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 Validate2Async( @@ -283,6 +467,7 @@ partial void ProcessValidate2Response( string? title = default, string? traceback = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.GCSSAImportStorageRequest @@ -310,6 +495,7 @@ partial void ProcessValidate2Response( await Validate2Async( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsSaClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsSaClient.g.cs index dde36cf..d257214 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsSaClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsSaClient.g.cs @@ -30,6 +30,9 @@ public sealed partial class StorageGcsSaClient : global::LabelStudio.IStorageGcs #if DEBUG = true; #endif + + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public StorageGcsSaClient( 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 StorageGcsSaClient. + /// 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 StorageGcsSaClient( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::LabelStudio.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::LabelStudio.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsWifClient.Create.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsWifClient.Create.g.cs index 8562ec0..cade2af 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsWifClient.Create.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsWifClient.Create.g.cs @@ -14,6 +14,7 @@ public partial class StorageGcsWifClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,11 +52,13 @@ partial void ProcessCreateResponseContent( /// Create an GCS export storage connection with WIF authentication to store annotations. ///
/// + /// 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 CreateAsync( global::LabelStudio.GCSWIFExportStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -72,22 +75,43 @@ partial void ProcessCreateResponseContent( securityRequirements: s_CreateSecurityRequirements, operationName: "CreateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/storages/export/gcswif", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/storages/export/gcswif", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -97,118 +121,277 @@ partial void ProcessCreateResponseContent( __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::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCreateRequest( - 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); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/storages/export/gcswif\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/storages/export/gcswif\"", + 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); - ProcessCreateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/storages/export/gcswif\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.GCSWIFExportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.GCSWIFExportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessCreateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/storages/export/gcswif\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/storages/export/gcswif\"", + 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); + ProcessCreateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.GCSWIFExportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.GCSWIFExportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 GCS export storage with WIF authentication
@@ -288,6 +471,7 @@ partial void ProcessCreateResponseContent( /// /// Interpret objects as BLOBs and generate URLs /// + /// 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 CreateAsync( @@ -312,6 +496,7 @@ partial void ProcessCreateResponseContent( string? title = default, string? traceback = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.GCSWIFExportStorageRequest @@ -341,6 +526,7 @@ partial void ProcessCreateResponseContent( return await CreateAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsWifClient.Create2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsWifClient.Create2.g.cs index 750ec10..1b72ff5 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsWifClient.Create2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsWifClient.Create2.g.cs @@ -14,6 +14,7 @@ public partial class StorageGcsWifClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,11 +52,13 @@ partial void ProcessCreate2ResponseContent( /// Create GCS import storage with WIF. ///
/// + /// 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 Create2Async( global::LabelStudio.GCSWIFImportStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -72,22 +75,43 @@ partial void ProcessCreate2ResponseContent( securityRequirements: s_Create2SecurityRequirements, operationName: "Create2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/storages/gcswif/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/storages/gcswif/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -97,118 +121,277 @@ partial void ProcessCreate2ResponseContent( __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::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCreate2Request( - 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); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreate2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreate2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "\"/api/storages/gcswif/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "\"/api/storages/gcswif/\"", + 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); - ProcessCreate2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "\"/api/storages/gcswif/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.GCSWIFImportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.GCSWIFImportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessCreate2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "\"/api/storages/gcswif/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "\"/api/storages/gcswif/\"", + 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); + ProcessCreate2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.GCSWIFImportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.GCSWIFImportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 GCS import storage with WIF
@@ -294,6 +477,7 @@ partial void ProcessCreate2ResponseContent( /// /// Interpret objects as BLOBs and generate URLs /// + /// 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 Create2Async( @@ -320,6 +504,7 @@ partial void ProcessCreate2ResponseContent( string? title = default, string? traceback = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.GCSWIFImportStorageRequest @@ -351,6 +536,7 @@ partial void ProcessCreate2ResponseContent( return await Create2Async( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsWifClient.Delete.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsWifClient.Delete.g.cs index a6ae856..33ccb07 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsWifClient.Delete.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsWifClient.Delete.g.cs @@ -14,6 +14,7 @@ public partial class StorageGcsWifClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -46,10 +47,12 @@ partial void ProcessDeleteResponse( /// Delete a specific GCS export storage connection that was set up with WIF authentication. ///
/// + /// 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 DeleteAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -64,22 +67,43 @@ partial void ProcessDeleteResponse( securityRequirements: s_DeleteSecurityRequirements, operationName: "DeleteAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/export/gcswif/{id}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/export/gcswif/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -89,96 +113,255 @@ partial void ProcessDeleteResponse( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDeleteRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDeleteRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/storages/export/gcswif/{id}\"", + 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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/storages/export/gcswif/{id}\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessDeleteResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/storages/export/gcswif/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessDeleteResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/storages/export/gcswif/{id}\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/storages/export/gcswif/{id}\"", + httpMethod: "DELETE", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageGcsWifClient.Delete2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsWifClient.Delete2.g.cs index 40f152b..cf87426 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsWifClient.Delete2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsWifClient.Delete2.g.cs @@ -14,6 +14,7 @@ public partial class StorageGcsWifClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -46,10 +47,12 @@ partial void ProcessDelete2Response( /// Delete a specific GCS import storage connection that was set up with WIF authentication. /// /// + /// 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 Delete2Async( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -64,22 +67,43 @@ partial void ProcessDelete2Response( securityRequirements: s_Delete2SecurityRequirements, operationName: "Delete2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/gcswif/{id}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/gcswif/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -89,96 +113,255 @@ partial void ProcessDelete2Response( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDelete2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDelete2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/storages/gcswif/{id}\"", + 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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/storages/gcswif/{id}\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessDelete2Response( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/storages/gcswif/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessDelete2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/storages/gcswif/{id}\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/storages/gcswif/{id}\"", + httpMethod: "DELETE", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageGcsWifClient.Get.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsWifClient.Get.g.cs index a5c803a..3808b1f 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsWifClient.Get.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsWifClient.Get.g.cs @@ -14,6 +14,7 @@ public partial class StorageGcsWifClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,10 +52,12 @@ partial void ProcessGetResponseContent( /// Get a specific GCS export storage connection that was set up with WIF authentication. /// /// + /// 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 GetAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -69,22 +72,43 @@ partial void ProcessGetResponseContent( securityRequirements: s_GetSecurityRequirements, operationName: "GetAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/export/gcswif/{id}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/export/gcswif/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,112 +118,271 @@ partial void ProcessGetResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/storages/export/gcswif/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/storages/export/gcswif/{id}\"", + 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); - ProcessGetResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/storages/export/gcswif/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.GCSWIFExportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.GCSWIFExportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGetResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/storages/export/gcswif/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/storages/export/gcswif/{id}\"", + 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); + ProcessGetResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.GCSWIFExportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.GCSWIFExportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageGcsWifClient.Get2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsWifClient.Get2.g.cs index 6fd47eb..695dd8b 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsWifClient.Get2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsWifClient.Get2.g.cs @@ -14,6 +14,7 @@ public partial class StorageGcsWifClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,10 +52,12 @@ partial void ProcessGet2ResponseContent( /// Get a specific GCS import storage connection that was set up with WIF. /// /// + /// 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 Get2Async( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -69,22 +72,43 @@ partial void ProcessGet2ResponseContent( securityRequirements: s_Get2SecurityRequirements, operationName: "Get2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/gcswif/{id}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/gcswif/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,112 +118,271 @@ partial void ProcessGet2ResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGet2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGet2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGet2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "$\"/api/storages/gcswif/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "$\"/api/storages/gcswif/{id}\"", + 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); - ProcessGet2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "$\"/api/storages/gcswif/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.GCSWIFImportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.GCSWIFImportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGet2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "$\"/api/storages/gcswif/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "$\"/api/storages/gcswif/{id}\"", + 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); + ProcessGet2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.GCSWIFImportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.GCSWIFImportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageGcsWifClient.List.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsWifClient.List.g.cs index 3f419b6..93f2c88 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsWifClient.List.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsWifClient.List.g.cs @@ -14,6 +14,7 @@ public partial class StorageGcsWifClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -54,11 +55,13 @@ partial void ProcessListResponseContent( /// /// /// + /// 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> ListAsync( int project, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -74,26 +77,47 @@ partial void ProcessListResponseContent( securityRequirements: s_ListSecurityRequirements, operationName: "ListAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/storages/export/gcswif", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("ordering", ordering) - .AddRequiredParameter("project", project.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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/storages/export/gcswif", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("ordering", ordering) + .AddRequiredParameter("project", project.ToString()!) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -103,113 +127,272 @@ partial void ProcessListResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareListRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - ordering: ordering, - project: project); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareListRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + ordering: ordering, + project: project); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessListResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/storages/export/gcswif\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/storages/export/gcswif\"", + 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); - ProcessListResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/storages/export/gcswif\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessListResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/storages/export/gcswif\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/storages/export/gcswif\"", + 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); + ProcessListResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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 + (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageGcsWifClient.List2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsWifClient.List2.g.cs index 0723fb3..ad493bb 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsWifClient.List2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsWifClient.List2.g.cs @@ -14,6 +14,7 @@ public partial class StorageGcsWifClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -54,11 +55,13 @@ partial void ProcessList2ResponseContent( /// /// /// + /// 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> List2Async( int project, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -74,26 +77,47 @@ partial void ProcessList2ResponseContent( securityRequirements: s_List2SecurityRequirements, operationName: "List2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/storages/gcswif/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("ordering", ordering) - .AddRequiredParameter("project", project.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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/storages/gcswif/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("ordering", ordering) + .AddRequiredParameter("project", project.ToString()!) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -103,113 +127,272 @@ partial void ProcessList2ResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareList2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - ordering: ordering, - project: project); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareList2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + ordering: ordering, + project: project); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessList2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/storages/gcswif/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/storages/gcswif/\"", + 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); - ProcessList2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/storages/gcswif/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessList2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/storages/gcswif/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/storages/gcswif/\"", + 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); + ProcessList2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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 + (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageGcsWifClient.Sync.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsWifClient.Sync.g.cs index 67e1e5d..cd5e696 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsWifClient.Sync.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsWifClient.Sync.g.cs @@ -14,6 +14,7 @@ public partial class StorageGcsWifClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,10 +52,12 @@ partial void ProcessSyncResponseContent( /// Sync tasks from an GCS WIF export 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 SyncAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -69,22 +72,43 @@ partial void ProcessSyncResponseContent( securityRequirements: s_SyncSecurityRequirements, operationName: "SyncAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/export/gcswif/{id}/sync", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/export/gcswif/{id}/sync", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,112 +118,271 @@ partial void ProcessSyncResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareSyncRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareSyncRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessSyncResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync", + methodName: "SyncAsync", + pathTemplate: "$\"/api/storages/export/gcswif/{id}/sync\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync", + methodName: "SyncAsync", + pathTemplate: "$\"/api/storages/export/gcswif/{id}/sync\"", + 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); - ProcessSyncResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync", + methodName: "SyncAsync", + pathTemplate: "$\"/api/storages/export/gcswif/{id}/sync\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.GCSWIFExportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.GCSWIFExportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessSyncResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync", + methodName: "SyncAsync", + pathTemplate: "$\"/api/storages/export/gcswif/{id}/sync\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync", + methodName: "SyncAsync", + pathTemplate: "$\"/api/storages/export/gcswif/{id}/sync\"", + 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); + ProcessSyncResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.GCSWIFExportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.GCSWIFExportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageGcsWifClient.Sync2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsWifClient.Sync2.g.cs index f2ce5d6..fde7b48 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsWifClient.Sync2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsWifClient.Sync2.g.cs @@ -14,6 +14,7 @@ public partial class StorageGcsWifClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,10 +52,12 @@ partial void ProcessSync2ResponseContent( /// Sync tasks from an GCS import storage connection that was set up with WIF authentication. /// /// + /// 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 Sync2Async( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -69,22 +72,43 @@ partial void ProcessSync2ResponseContent( securityRequirements: s_Sync2SecurityRequirements, operationName: "Sync2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/gcswif/{id}/sync", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/gcswif/{id}/sync", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,112 +118,271 @@ partial void ProcessSync2ResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareSync2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareSync2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessSync2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync2", + methodName: "Sync2Async", + pathTemplate: "$\"/api/storages/gcswif/{id}/sync\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync2", + methodName: "Sync2Async", + pathTemplate: "$\"/api/storages/gcswif/{id}/sync\"", + 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); - ProcessSync2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync2", + methodName: "Sync2Async", + pathTemplate: "$\"/api/storages/gcswif/{id}/sync\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.GCSWIFImportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.GCSWIFImportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessSync2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync2", + methodName: "Sync2Async", + pathTemplate: "$\"/api/storages/gcswif/{id}/sync\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync2", + methodName: "Sync2Async", + pathTemplate: "$\"/api/storages/gcswif/{id}/sync\"", + 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); + ProcessSync2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.GCSWIFImportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.GCSWIFImportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageGcsWifClient.Update.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsWifClient.Update.g.cs index 1cf389e..65e8e20 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsWifClient.Update.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsWifClient.Update.g.cs @@ -14,6 +14,7 @@ public partial class StorageGcsWifClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -54,12 +55,14 @@ partial void ProcessUpdateResponseContent( /// /// /// + /// 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 UpdateAsync( int id, global::LabelStudio.PatchedGCSWIFExportStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -77,22 +80,43 @@ partial void ProcessUpdateResponseContent( securityRequirements: s_UpdateSecurityRequirements, operationName: "UpdateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/export/gcswif/{id}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/export/gcswif/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -102,119 +126,278 @@ partial void ProcessUpdateResponseContent( __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); - PrepareUpdateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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::LabelStudio.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); + PrepareUpdateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessUpdateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/storages/export/gcswif/{id}\"", + 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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/storages/export/gcswif/{id}\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessUpdateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/storages/export/gcswif/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.GCSWIFExportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.GCSWIFExportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessUpdateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/storages/export/gcswif/{id}\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/storages/export/gcswif/{id}\"", + httpMethod: "PATCH", + 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); + ProcessUpdateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.GCSWIFExportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.GCSWIFExportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 GCS WIF export storage
@@ -295,6 +478,7 @@ partial void ProcessUpdateResponseContent( /// /// Interpret objects as BLOBs and generate URLs /// + /// 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 UpdateAsync( @@ -320,6 +504,7 @@ partial void ProcessUpdateResponseContent( string? title = default, string? traceback = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.PatchedGCSWIFExportStorageRequest @@ -350,6 +535,7 @@ partial void ProcessUpdateResponseContent( return await UpdateAsync( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsWifClient.Update2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsWifClient.Update2.g.cs index dc53d6a..7b04e25 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsWifClient.Update2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsWifClient.Update2.g.cs @@ -14,6 +14,7 @@ public partial class StorageGcsWifClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -54,12 +55,14 @@ partial void ProcessUpdate2ResponseContent( ///
/// /// + /// 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 Update2Async( int id, global::LabelStudio.PatchedGCSWIFImportStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -77,22 +80,43 @@ partial void ProcessUpdate2ResponseContent( securityRequirements: s_Update2SecurityRequirements, operationName: "Update2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/gcswif/{id}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/gcswif/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -102,119 +126,278 @@ partial void ProcessUpdate2ResponseContent( __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); - PrepareUpdate2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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::LabelStudio.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); + PrepareUpdate2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessUpdate2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/storages/gcswif/{id}\"", + 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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/storages/gcswif/{id}\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessUpdate2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/storages/gcswif/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.GCSWIFImportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.GCSWIFImportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessUpdate2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/storages/gcswif/{id}\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/storages/gcswif/{id}\"", + httpMethod: "PATCH", + 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); + ProcessUpdate2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.GCSWIFImportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.GCSWIFImportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 GCS WIF import storage
@@ -301,6 +484,7 @@ partial void ProcessUpdate2ResponseContent( /// /// Interpret objects as BLOBs and generate URLs /// + /// 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 Update2Async( @@ -328,6 +512,7 @@ partial void ProcessUpdate2ResponseContent( string? title = default, string? traceback = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.PatchedGCSWIFImportStorageRequest @@ -360,6 +545,7 @@ partial void ProcessUpdate2ResponseContent( return await Update2Async( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsWifClient.Validate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsWifClient.Validate.g.cs index 8f0abb1..225dd6b 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsWifClient.Validate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsWifClient.Validate.g.cs @@ -14,6 +14,7 @@ public partial class StorageGcsWifClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -46,11 +47,13 @@ partial void ProcessValidateResponse( /// Validate a specific GCS export storage connection that was set up with WIF authentication. ///
/// + /// 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 ValidateAsync( global::LabelStudio.GCSWIFExportStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -67,22 +70,43 @@ partial void ProcessValidateResponse( securityRequirements: s_ValidateSecurityRequirements, operationName: "ValidateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/storages/export/gcswif/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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/storages/export/gcswif/validate", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -92,102 +116,261 @@ partial void ProcessValidateResponse( __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::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareValidateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - request: request); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareValidateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate", + methodName: "ValidateAsync", + pathTemplate: "\"/api/storages/export/gcswif/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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate", + methodName: "ValidateAsync", + pathTemplate: "\"/api/storages/export/gcswif/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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessValidateResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate", + methodName: "ValidateAsync", + pathTemplate: "\"/api/storages/export/gcswif/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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessValidateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate", + methodName: "ValidateAsync", + pathTemplate: "\"/api/storages/export/gcswif/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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate", + methodName: "ValidateAsync", + pathTemplate: "\"/api/storages/export/gcswif/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); + } + + 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 GCS WIF export storage
@@ -267,6 +450,7 @@ partial void ProcessValidateResponse( /// /// Interpret objects as BLOBs and generate URLs /// + /// 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 ValidateAsync( @@ -291,6 +475,7 @@ partial void ProcessValidateResponse( string? title = default, string? traceback = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.GCSWIFExportStorageRequest @@ -320,6 +505,7 @@ partial void ProcessValidateResponse( await ValidateAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsWifClient.Validate2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsWifClient.Validate2.g.cs index 5c21929..60d3264 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsWifClient.Validate2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsWifClient.Validate2.g.cs @@ -14,6 +14,7 @@ public partial class StorageGcsWifClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -46,11 +47,13 @@ partial void ProcessValidate2Response( /// Validate a specific GCS import storage connection that was set up with WIF authentication. ///
/// + /// 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 Validate2Async( global::LabelStudio.GCSWIFImportStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -67,22 +70,43 @@ partial void ProcessValidate2Response( securityRequirements: s_Validate2SecurityRequirements, operationName: "Validate2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/storages/gcswif/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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/storages/gcswif/validate", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -92,102 +116,261 @@ partial void ProcessValidate2Response( __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::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareValidate2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - request: request); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareValidate2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate2", + methodName: "Validate2Async", + pathTemplate: "\"/api/storages/gcswif/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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate2", + methodName: "Validate2Async", + pathTemplate: "\"/api/storages/gcswif/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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessValidate2Response( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate2", + methodName: "Validate2Async", + pathTemplate: "\"/api/storages/gcswif/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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessValidate2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate2", + methodName: "Validate2Async", + pathTemplate: "\"/api/storages/gcswif/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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate2", + methodName: "Validate2Async", + pathTemplate: "\"/api/storages/gcswif/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); + } + + 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 GCS WIF import storage
@@ -273,6 +456,7 @@ partial void ProcessValidate2Response( /// /// Interpret objects as BLOBs and generate URLs /// + /// 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 Validate2Async( @@ -299,6 +483,7 @@ partial void ProcessValidate2Response( string? title = default, string? traceback = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.GCSWIFImportStorageRequest @@ -330,6 +515,7 @@ partial void ProcessValidate2Response( await Validate2Async( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsWifClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsWifClient.g.cs index 6fdf970..a6febf4 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsWifClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageGcsWifClient.g.cs @@ -30,6 +30,9 @@ public sealed partial class StorageGcsWifClient : global::LabelStudio.IStorageGc #if DEBUG = true; #endif + + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public StorageGcsWifClient( 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 StorageGcsWifClient. + /// 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 StorageGcsWifClient( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::LabelStudio.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::LabelStudio.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StorageLocalClient.Create.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageLocalClient.Create.g.cs index c9c6fd3..301da08 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageLocalClient.Create.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageLocalClient.Create.g.cs @@ -14,6 +14,7 @@ public partial class StorageLocalClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,11 +46,13 @@ partial void ProcessCreateResponseContent( /// Create a new local file export storage connection to store annotations. ///
/// + /// 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 CreateAsync( global::LabelStudio.ApiStoragesExportLocalfilesCreateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -66,22 +69,43 @@ partial void ProcessCreateResponseContent( securityRequirements: s_CreateSecurityRequirements, operationName: "CreateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/storages/export/localfiles", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/storages/export/localfiles", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,118 +115,277 @@ partial void ProcessCreateResponseContent( __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::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCreateRequest( - 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); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/storages/export/localfiles\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/storages/export/localfiles\"", + 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); - ProcessCreateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/storages/export/localfiles\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.LocalFilesExportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.LocalFilesExportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessCreateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/storages/export/localfiles\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/storages/export/localfiles\"", + 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); + ProcessCreateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.LocalFilesExportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.LocalFilesExportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 export storage
@@ -227,6 +410,7 @@ partial void ProcessCreateResponseContent( /// Interpret objects as BLOBs and generate URLs. For example, if your directory contains images, you can use this option to generate URLs for these images. If set to False, it will read the content of the file and load it into Label Studio.
/// 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 CreateAsync( @@ -236,6 +420,7 @@ partial void ProcessCreateResponseContent( string? regexFilter = default, string? title = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.ApiStoragesExportLocalfilesCreateRequest @@ -250,6 +435,7 @@ partial void ProcessCreateResponseContent( return await CreateAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StorageLocalClient.Create2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageLocalClient.Create2.g.cs index 1cc4ce5..51cc7bb 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageLocalClient.Create2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageLocalClient.Create2.g.cs @@ -14,6 +14,7 @@ public partial class StorageLocalClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,11 +46,13 @@ partial void ProcessCreate2ResponseContent( /// Create a new local file import storage connection. ///
/// + /// 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 Create2Async( global::LabelStudio.ApiStoragesLocalfilesCreateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -66,22 +69,43 @@ partial void ProcessCreate2ResponseContent( securityRequirements: s_Create2SecurityRequirements, operationName: "Create2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/storages/localfiles/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/storages/localfiles/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,118 +115,277 @@ partial void ProcessCreate2ResponseContent( __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::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCreate2Request( - 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); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreate2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreate2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "\"/api/storages/localfiles/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "\"/api/storages/localfiles/\"", + 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); - ProcessCreate2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "\"/api/storages/localfiles/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.LocalFilesImportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.LocalFilesImportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessCreate2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "\"/api/storages/localfiles/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "\"/api/storages/localfiles/\"", + 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); + ProcessCreate2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.LocalFilesImportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.LocalFilesImportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 import storage
@@ -227,6 +410,7 @@ partial void ProcessCreate2ResponseContent( /// Interpret objects as BLOBs and generate URLs. For example, if your directory contains images, you can use this option to generate URLs for these images. If set to False, it will read the content of the file and load it into Label Studio.
/// 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 Create2Async( @@ -236,6 +420,7 @@ partial void ProcessCreate2ResponseContent( string? regexFilter = default, string? title = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.ApiStoragesLocalfilesCreateRequest @@ -250,6 +435,7 @@ partial void ProcessCreate2ResponseContent( return await Create2Async( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StorageLocalClient.Delete.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageLocalClient.Delete.g.cs index 692abc7..38bce4b 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageLocalClient.Delete.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageLocalClient.Delete.g.cs @@ -14,6 +14,7 @@ public partial class StorageLocalClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -40,10 +41,12 @@ partial void ProcessDeleteResponse( /// Delete a specific local file export storage connection. ///
/// + /// 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 DeleteAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -58,22 +61,43 @@ partial void ProcessDeleteResponse( securityRequirements: s_DeleteSecurityRequirements, operationName: "DeleteAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/export/localfiles/{id}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/export/localfiles/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -83,96 +107,255 @@ partial void ProcessDeleteResponse( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDeleteRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDeleteRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/storages/export/localfiles/{id}\"", + 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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/storages/export/localfiles/{id}\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessDeleteResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/storages/export/localfiles/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessDeleteResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/storages/export/localfiles/{id}\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/storages/export/localfiles/{id}\"", + httpMethod: "DELETE", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageLocalClient.Delete2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageLocalClient.Delete2.g.cs index c8270c2..89e1c51 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageLocalClient.Delete2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageLocalClient.Delete2.g.cs @@ -14,6 +14,7 @@ public partial class StorageLocalClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -40,10 +41,12 @@ partial void ProcessDelete2Response( /// Delete a specific local file import storage connection. /// /// + /// 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 Delete2Async( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -58,22 +61,43 @@ partial void ProcessDelete2Response( securityRequirements: s_Delete2SecurityRequirements, operationName: "Delete2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/localfiles/{id}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/localfiles/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -83,96 +107,255 @@ partial void ProcessDelete2Response( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDelete2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDelete2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/storages/localfiles/{id}\"", + 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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/storages/localfiles/{id}\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessDelete2Response( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/storages/localfiles/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessDelete2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/storages/localfiles/{id}\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/storages/localfiles/{id}\"", + httpMethod: "DELETE", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageLocalClient.Get.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageLocalClient.Get.g.cs index 4ed9cd1..921f0c1 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageLocalClient.Get.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageLocalClient.Get.g.cs @@ -14,6 +14,7 @@ public partial class StorageLocalClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,10 +46,12 @@ partial void ProcessGetResponseContent( /// Get a specific local file export storage connection. /// /// + /// 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 GetAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -63,22 +66,43 @@ partial void ProcessGetResponseContent( securityRequirements: s_GetSecurityRequirements, operationName: "GetAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/export/localfiles/{id}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/export/localfiles/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -88,112 +112,271 @@ partial void ProcessGetResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/storages/export/localfiles/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/storages/export/localfiles/{id}\"", + 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); - ProcessGetResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/storages/export/localfiles/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.LocalFilesExportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.LocalFilesExportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGetResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/storages/export/localfiles/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/storages/export/localfiles/{id}\"", + 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); + ProcessGetResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.LocalFilesExportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.LocalFilesExportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageLocalClient.Get2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageLocalClient.Get2.g.cs index 7abcf2f..ce975ed 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageLocalClient.Get2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageLocalClient.Get2.g.cs @@ -14,6 +14,7 @@ public partial class StorageLocalClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,10 +46,12 @@ partial void ProcessGet2ResponseContent( /// Get a specific local file import storage connection. /// /// + /// 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 Get2Async( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -63,22 +66,43 @@ partial void ProcessGet2ResponseContent( securityRequirements: s_Get2SecurityRequirements, operationName: "Get2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/localfiles/{id}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/localfiles/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -88,112 +112,271 @@ partial void ProcessGet2ResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGet2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGet2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGet2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "$\"/api/storages/localfiles/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "$\"/api/storages/localfiles/{id}\"", + 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); - ProcessGet2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "$\"/api/storages/localfiles/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.LocalFilesImportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.LocalFilesImportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGet2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "$\"/api/storages/localfiles/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "$\"/api/storages/localfiles/{id}\"", + 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); + ProcessGet2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.LocalFilesImportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.LocalFilesImportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageLocalClient.List.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageLocalClient.List.g.cs index cccd05d..0a0d1fc 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageLocalClient.List.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageLocalClient.List.g.cs @@ -14,6 +14,7 @@ public partial class StorageLocalClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -48,11 +49,13 @@ partial void ProcessListResponseContent( /// /// /// + /// 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> ListAsync( int project, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -68,26 +71,47 @@ partial void ProcessListResponseContent( securityRequirements: s_ListSecurityRequirements, operationName: "ListAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/storages/export/localfiles", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("ordering", ordering) - .AddRequiredParameter("project", project.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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/storages/export/localfiles", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("ordering", ordering) + .AddRequiredParameter("project", project.ToString()!) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -97,113 +121,272 @@ partial void ProcessListResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareListRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - ordering: ordering, - project: project); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareListRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + ordering: ordering, + project: project); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessListResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/storages/export/localfiles\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/storages/export/localfiles\"", + 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); - ProcessListResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/storages/export/localfiles\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessListResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/storages/export/localfiles\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/storages/export/localfiles\"", + 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); + ProcessListResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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 + (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageLocalClient.List2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageLocalClient.List2.g.cs index 7710b5b..8b4a877 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageLocalClient.List2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageLocalClient.List2.g.cs @@ -14,6 +14,7 @@ public partial class StorageLocalClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -48,11 +49,13 @@ partial void ProcessList2ResponseContent( /// /// /// + /// 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> List2Async( int project, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -68,26 +71,47 @@ partial void ProcessList2ResponseContent( securityRequirements: s_List2SecurityRequirements, operationName: "List2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/storages/localfiles/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("ordering", ordering) - .AddRequiredParameter("project", project.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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/storages/localfiles/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("ordering", ordering) + .AddRequiredParameter("project", project.ToString()!) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -97,113 +121,272 @@ partial void ProcessList2ResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareList2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - ordering: ordering, - project: project); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareList2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + ordering: ordering, + project: project); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessList2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/storages/localfiles/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/storages/localfiles/\"", + 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); - ProcessList2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/storages/localfiles/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessList2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/storages/localfiles/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/storages/localfiles/\"", + 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); + ProcessList2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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 + (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageLocalClient.Sync.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageLocalClient.Sync.g.cs index 89b06b4..37a9a59 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageLocalClient.Sync.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageLocalClient.Sync.g.cs @@ -14,6 +14,7 @@ public partial class StorageLocalClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,10 +46,12 @@ partial void ProcessSyncResponseContent( /// Sync tasks from a local file export storage connection. /// /// + /// 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 SyncAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -63,22 +66,43 @@ partial void ProcessSyncResponseContent( securityRequirements: s_SyncSecurityRequirements, operationName: "SyncAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/export/localfiles/{id}/sync", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/export/localfiles/{id}/sync", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -88,112 +112,271 @@ partial void ProcessSyncResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareSyncRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareSyncRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessSyncResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync", + methodName: "SyncAsync", + pathTemplate: "$\"/api/storages/export/localfiles/{id}/sync\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync", + methodName: "SyncAsync", + pathTemplate: "$\"/api/storages/export/localfiles/{id}/sync\"", + 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); - ProcessSyncResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync", + methodName: "SyncAsync", + pathTemplate: "$\"/api/storages/export/localfiles/{id}/sync\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.LocalFilesExportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.LocalFilesExportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessSyncResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync", + methodName: "SyncAsync", + pathTemplate: "$\"/api/storages/export/localfiles/{id}/sync\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync", + methodName: "SyncAsync", + pathTemplate: "$\"/api/storages/export/localfiles/{id}/sync\"", + 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); + ProcessSyncResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.LocalFilesExportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.LocalFilesExportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageLocalClient.Sync2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageLocalClient.Sync2.g.cs index 52057f1..ac1dca8 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageLocalClient.Sync2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageLocalClient.Sync2.g.cs @@ -14,6 +14,7 @@ public partial class StorageLocalClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,10 +46,12 @@ partial void ProcessSync2ResponseContent( /// Sync tasks from a local file import storage connection. /// /// + /// 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 Sync2Async( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -63,22 +66,43 @@ partial void ProcessSync2ResponseContent( securityRequirements: s_Sync2SecurityRequirements, operationName: "Sync2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/localfiles/{id}/sync", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/localfiles/{id}/sync", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -88,112 +112,271 @@ partial void ProcessSync2ResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareSync2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareSync2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessSync2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync2", + methodName: "Sync2Async", + pathTemplate: "$\"/api/storages/localfiles/{id}/sync\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync2", + methodName: "Sync2Async", + pathTemplate: "$\"/api/storages/localfiles/{id}/sync\"", + 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); - ProcessSync2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync2", + methodName: "Sync2Async", + pathTemplate: "$\"/api/storages/localfiles/{id}/sync\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.LocalFilesImportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.LocalFilesImportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessSync2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync2", + methodName: "Sync2Async", + pathTemplate: "$\"/api/storages/localfiles/{id}/sync\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync2", + methodName: "Sync2Async", + pathTemplate: "$\"/api/storages/localfiles/{id}/sync\"", + 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); + ProcessSync2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.LocalFilesImportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.LocalFilesImportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageLocalClient.Update.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageLocalClient.Update.g.cs index bf72f4f..4250876 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageLocalClient.Update.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageLocalClient.Update.g.cs @@ -14,6 +14,7 @@ public partial class StorageLocalClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -48,12 +49,14 @@ partial void ProcessUpdateResponseContent( /// /// /// + /// 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 UpdateAsync( int id, global::LabelStudio.ApiStoragesExportLocalfilesPartialUpdateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -71,22 +74,43 @@ partial void ProcessUpdateResponseContent( securityRequirements: s_UpdateSecurityRequirements, operationName: "UpdateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/export/localfiles/{id}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/export/localfiles/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -96,119 +120,278 @@ partial void ProcessUpdateResponseContent( __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); - PrepareUpdateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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::LabelStudio.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); + PrepareUpdateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessUpdateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/storages/export/localfiles/{id}\"", + 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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/storages/export/localfiles/{id}\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessUpdateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/storages/export/localfiles/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.LocalFilesExportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.LocalFilesExportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessUpdateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/storages/export/localfiles/{id}\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/storages/export/localfiles/{id}\"", + httpMethod: "PATCH", + 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); + ProcessUpdateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.LocalFilesExportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.LocalFilesExportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 export storage
@@ -234,6 +417,7 @@ partial void ProcessUpdateResponseContent( /// Interpret objects as BLOBs and generate URLs. For example, if your directory contains images, you can use this option to generate URLs for these images. If set to False, it will read the content of the file and load it into Label Studio.
/// 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 UpdateAsync( @@ -244,6 +428,7 @@ partial void ProcessUpdateResponseContent( string? regexFilter = default, string? title = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.ApiStoragesExportLocalfilesPartialUpdateRequest @@ -259,6 +444,7 @@ partial void ProcessUpdateResponseContent( return await UpdateAsync( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StorageLocalClient.Update2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageLocalClient.Update2.g.cs index efc413b..89ad977 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageLocalClient.Update2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageLocalClient.Update2.g.cs @@ -14,6 +14,7 @@ public partial class StorageLocalClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -48,12 +49,14 @@ partial void ProcessUpdate2ResponseContent( ///
/// /// + /// 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 Update2Async( int id, global::LabelStudio.ApiStoragesLocalfilesPartialUpdateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -71,22 +74,43 @@ partial void ProcessUpdate2ResponseContent( securityRequirements: s_Update2SecurityRequirements, operationName: "Update2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/localfiles/{id}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/localfiles/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -96,119 +120,278 @@ partial void ProcessUpdate2ResponseContent( __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); - PrepareUpdate2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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::LabelStudio.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); + PrepareUpdate2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessUpdate2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/storages/localfiles/{id}\"", + 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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/storages/localfiles/{id}\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessUpdate2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/storages/localfiles/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.LocalFilesImportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.LocalFilesImportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessUpdate2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/storages/localfiles/{id}\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/storages/localfiles/{id}\"", + httpMethod: "PATCH", + 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); + ProcessUpdate2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.LocalFilesImportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.LocalFilesImportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 import storage
@@ -234,6 +417,7 @@ partial void ProcessUpdate2ResponseContent( /// Interpret objects as BLOBs and generate URLs. For example, if your directory contains images, you can use this option to generate URLs for these images. If set to False, it will read the content of the file and load it into Label Studio.
/// 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 Update2Async( @@ -244,6 +428,7 @@ partial void ProcessUpdate2ResponseContent( string? regexFilter = default, string? title = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.ApiStoragesLocalfilesPartialUpdateRequest @@ -259,6 +444,7 @@ partial void ProcessUpdate2ResponseContent( return await Update2Async( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StorageLocalClient.Validate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageLocalClient.Validate.g.cs index 6a0eed3..b88389f 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageLocalClient.Validate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageLocalClient.Validate.g.cs @@ -14,6 +14,7 @@ public partial class StorageLocalClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -40,11 +41,13 @@ partial void ProcessValidateResponse( /// Validate a specific local file export storage connection. ///
/// + /// 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 ValidateAsync( global::LabelStudio.ApiStoragesExportLocalfilesValidateCreateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -61,22 +64,43 @@ partial void ProcessValidateResponse( securityRequirements: s_ValidateSecurityRequirements, operationName: "ValidateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/storages/export/localfiles/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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/storages/export/localfiles/validate", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -86,102 +110,261 @@ partial void ProcessValidateResponse( __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); - PrepareValidateRequest( - 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::LabelStudio.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); + PrepareValidateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessValidateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate", + methodName: "ValidateAsync", + pathTemplate: "\"/api/storages/export/localfiles/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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate", + methodName: "ValidateAsync", + pathTemplate: "\"/api/storages/export/localfiles/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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate", + methodName: "ValidateAsync", + pathTemplate: "\"/api/storages/export/localfiles/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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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) + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessValidateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate", + methodName: "ValidateAsync", + pathTemplate: "\"/api/storages/export/localfiles/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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate", + methodName: "ValidateAsync", + pathTemplate: "\"/api/storages/export/localfiles/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); + } + + 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 export storage
@@ -209,6 +392,7 @@ partial void ProcessValidateResponse( /// Interpret objects as BLOBs and generate URLs. For example, if your directory contains images, you can use this option to generate URLs for these images. If set to False, it will read the content of the file and load it into Label Studio.
/// 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 ValidateAsync( @@ -219,6 +403,7 @@ partial void ProcessValidateResponse( string? regexFilter = default, string? title = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.ApiStoragesExportLocalfilesValidateCreateRequest @@ -234,6 +419,7 @@ partial void ProcessValidateResponse( await ValidateAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StorageLocalClient.Validate2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageLocalClient.Validate2.g.cs index 66cf341..b069d53 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageLocalClient.Validate2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageLocalClient.Validate2.g.cs @@ -14,6 +14,7 @@ public partial class StorageLocalClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -40,11 +41,13 @@ partial void ProcessValidate2Response( /// Validate a specific local file import storage connection. ///
/// + /// 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 Validate2Async( global::LabelStudio.ApiStoragesLocalfilesValidateCreateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -61,22 +64,43 @@ partial void ProcessValidate2Response( securityRequirements: s_Validate2SecurityRequirements, operationName: "Validate2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/storages/localfiles/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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/storages/localfiles/validate", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -86,102 +110,261 @@ partial void ProcessValidate2Response( __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); - PrepareValidate2Request( - 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::LabelStudio.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); + PrepareValidate2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessValidate2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate2", + methodName: "Validate2Async", + pathTemplate: "\"/api/storages/localfiles/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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate2", + methodName: "Validate2Async", + pathTemplate: "\"/api/storages/localfiles/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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate2", + methodName: "Validate2Async", + pathTemplate: "\"/api/storages/localfiles/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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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) + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessValidate2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate2", + methodName: "Validate2Async", + pathTemplate: "\"/api/storages/localfiles/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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate2", + methodName: "Validate2Async", + pathTemplate: "\"/api/storages/localfiles/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); + } + + 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 import storage
@@ -209,6 +392,7 @@ partial void ProcessValidate2Response( /// Interpret objects as BLOBs and generate URLs. For example, if your directory contains images, you can use this option to generate URLs for these images. If set to False, it will read the content of the file and load it into Label Studio.
/// 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 Validate2Async( @@ -219,6 +403,7 @@ partial void ProcessValidate2Response( string? regexFilter = default, string? title = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.ApiStoragesLocalfilesValidateCreateRequest @@ -234,6 +419,7 @@ partial void ProcessValidate2Response( await Validate2Async( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StorageLocalClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageLocalClient.g.cs index 97b4c22..49b9960 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageLocalClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageLocalClient.g.cs @@ -30,6 +30,9 @@ public sealed partial class StorageLocalClient : global::LabelStudio.IStorageLoc #if DEBUG = true; #endif + + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public StorageLocalClient( 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 StorageLocalClient. + /// 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 StorageLocalClient( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::LabelStudio.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::LabelStudio.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StorageRedisClient.Create.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageRedisClient.Create.g.cs index 35ade96..e3ddcc2 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageRedisClient.Create.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageRedisClient.Create.g.cs @@ -14,6 +14,7 @@ public partial class StorageRedisClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,11 +46,13 @@ partial void ProcessCreateResponseContent( /// Create a new Redis export storage connection to store annotations. ///
/// + /// 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 CreateAsync( global::LabelStudio.ApiStoragesExportRedisCreateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -66,22 +69,43 @@ partial void ProcessCreateResponseContent( securityRequirements: s_CreateSecurityRequirements, operationName: "CreateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/storages/export/redis", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/storages/export/redis", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,118 +115,277 @@ partial void ProcessCreateResponseContent( __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::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCreateRequest( - 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); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/storages/export/redis\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/storages/export/redis\"", + 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); - ProcessCreateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/storages/export/redis\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.RedisExportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.RedisExportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessCreateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/storages/export/redis\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/storages/export/redis\"", + 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); + ProcessCreateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.RedisExportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.RedisExportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 export storage
@@ -236,6 +419,7 @@ partial void ProcessCreateResponseContent( /// /// Storage title /// + /// 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 CreateAsync( @@ -248,6 +432,7 @@ partial void ProcessCreateResponseContent( string? port = default, int? project = default, string? title = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.ApiStoragesExportRedisCreateRequest @@ -265,6 +450,7 @@ partial void ProcessCreateResponseContent( return await CreateAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StorageRedisClient.Create2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageRedisClient.Create2.g.cs index c6053ea..4571c94 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageRedisClient.Create2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageRedisClient.Create2.g.cs @@ -14,6 +14,7 @@ public partial class StorageRedisClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,11 +46,13 @@ partial void ProcessCreate2ResponseContent( /// Create a new Redis import storage connection. ///
/// + /// 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 Create2Async( global::LabelStudio.ApiStoragesRedisCreateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -66,22 +69,43 @@ partial void ProcessCreate2ResponseContent( securityRequirements: s_Create2SecurityRequirements, operationName: "Create2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/storages/redis/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/storages/redis/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,118 +115,277 @@ partial void ProcessCreate2ResponseContent( __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::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCreate2Request( - 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); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreate2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreate2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "\"/api/storages/redis/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "\"/api/storages/redis/\"", + 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); - ProcessCreate2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "\"/api/storages/redis/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.RedisImportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.RedisImportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessCreate2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "\"/api/storages/redis/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "\"/api/storages/redis/\"", + 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); + ProcessCreate2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.RedisImportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.RedisImportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 import storage
@@ -236,6 +419,7 @@ partial void ProcessCreate2ResponseContent( /// Interpret objects as BLOBs and generate URLs. For example, if your bucket contains images, you can use this option to generate URLs for these images. If set to False, it will read the content of the file and load it into Label Studio.
/// 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 Create2Async( @@ -248,6 +432,7 @@ partial void ProcessCreate2ResponseContent( string? regexFilter = default, string? title = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.ApiStoragesRedisCreateRequest @@ -265,6 +450,7 @@ partial void ProcessCreate2ResponseContent( return await Create2Async( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StorageRedisClient.Delete.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageRedisClient.Delete.g.cs index 6cb756b..0eb7b55 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageRedisClient.Delete.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageRedisClient.Delete.g.cs @@ -14,6 +14,7 @@ public partial class StorageRedisClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -40,10 +41,12 @@ partial void ProcessDeleteResponse( /// Delete a specific Redis export storage connection. ///
/// + /// 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 DeleteAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -58,22 +61,43 @@ partial void ProcessDeleteResponse( securityRequirements: s_DeleteSecurityRequirements, operationName: "DeleteAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/export/redis/{id}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/export/redis/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -83,96 +107,255 @@ partial void ProcessDeleteResponse( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDeleteRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDeleteRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/storages/export/redis/{id}\"", + 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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/storages/export/redis/{id}\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessDeleteResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/storages/export/redis/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessDeleteResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/storages/export/redis/{id}\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/storages/export/redis/{id}\"", + httpMethod: "DELETE", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageRedisClient.Delete2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageRedisClient.Delete2.g.cs index 28dff09..edd511c 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageRedisClient.Delete2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageRedisClient.Delete2.g.cs @@ -14,6 +14,7 @@ public partial class StorageRedisClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -40,10 +41,12 @@ partial void ProcessDelete2Response( /// Delete a specific Redis import storage connection. /// /// + /// 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 Delete2Async( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -58,22 +61,43 @@ partial void ProcessDelete2Response( securityRequirements: s_Delete2SecurityRequirements, operationName: "Delete2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/redis/{id}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/redis/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -83,96 +107,255 @@ partial void ProcessDelete2Response( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDelete2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDelete2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/storages/redis/{id}\"", + 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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/storages/redis/{id}\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessDelete2Response( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/storages/redis/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessDelete2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/storages/redis/{id}\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/storages/redis/{id}\"", + httpMethod: "DELETE", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageRedisClient.Get.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageRedisClient.Get.g.cs index 30d30c4..0d3e571 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageRedisClient.Get.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageRedisClient.Get.g.cs @@ -14,6 +14,7 @@ public partial class StorageRedisClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,10 +46,12 @@ partial void ProcessGetResponseContent( /// Get a specific Redis export storage connection. /// /// + /// 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 GetAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -63,22 +66,43 @@ partial void ProcessGetResponseContent( securityRequirements: s_GetSecurityRequirements, operationName: "GetAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/export/redis/{id}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/export/redis/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -88,112 +112,271 @@ partial void ProcessGetResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/storages/export/redis/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/storages/export/redis/{id}\"", + 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); - ProcessGetResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/storages/export/redis/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.RedisExportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.RedisExportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGetResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/storages/export/redis/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/storages/export/redis/{id}\"", + 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); + ProcessGetResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.RedisExportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.RedisExportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageRedisClient.Get2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageRedisClient.Get2.g.cs index b9db0e0..569dfec 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageRedisClient.Get2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageRedisClient.Get2.g.cs @@ -14,6 +14,7 @@ public partial class StorageRedisClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,10 +46,12 @@ partial void ProcessGet2ResponseContent( /// Get a specific Redis import storage connection. /// /// + /// 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 Get2Async( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -63,22 +66,43 @@ partial void ProcessGet2ResponseContent( securityRequirements: s_Get2SecurityRequirements, operationName: "Get2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/redis/{id}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/redis/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -88,112 +112,271 @@ partial void ProcessGet2ResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGet2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGet2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGet2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "$\"/api/storages/redis/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "$\"/api/storages/redis/{id}\"", + 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); - ProcessGet2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "$\"/api/storages/redis/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.RedisImportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.RedisImportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGet2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "$\"/api/storages/redis/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "$\"/api/storages/redis/{id}\"", + 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); + ProcessGet2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.RedisImportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.RedisImportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageRedisClient.List.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageRedisClient.List.g.cs index 774bbac..178e4e1 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageRedisClient.List.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageRedisClient.List.g.cs @@ -14,6 +14,7 @@ public partial class StorageRedisClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -48,11 +49,13 @@ partial void ProcessListResponseContent( /// /// /// + /// 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> ListAsync( int project, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -68,26 +71,47 @@ partial void ProcessListResponseContent( securityRequirements: s_ListSecurityRequirements, operationName: "ListAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/storages/export/redis", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("ordering", ordering) - .AddRequiredParameter("project", project.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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/storages/export/redis", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("ordering", ordering) + .AddRequiredParameter("project", project.ToString()!) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -97,113 +121,272 @@ partial void ProcessListResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareListRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - ordering: ordering, - project: project); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareListRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + ordering: ordering, + project: project); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessListResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/storages/export/redis\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/storages/export/redis\"", + 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); - ProcessListResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/storages/export/redis\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessListResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/storages/export/redis\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/storages/export/redis\"", + 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); + ProcessListResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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 + (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageRedisClient.List2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageRedisClient.List2.g.cs index d3862d6..0ac2d4d 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageRedisClient.List2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageRedisClient.List2.g.cs @@ -14,6 +14,7 @@ public partial class StorageRedisClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -48,11 +49,13 @@ partial void ProcessList2ResponseContent( /// /// /// + /// 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> List2Async( int project, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -68,26 +71,47 @@ partial void ProcessList2ResponseContent( securityRequirements: s_List2SecurityRequirements, operationName: "List2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/storages/redis/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("ordering", ordering) - .AddRequiredParameter("project", project.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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/storages/redis/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("ordering", ordering) + .AddRequiredParameter("project", project.ToString()!) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -97,113 +121,272 @@ partial void ProcessList2ResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareList2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - ordering: ordering, - project: project); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareList2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + ordering: ordering, + project: project); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessList2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/storages/redis/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/storages/redis/\"", + 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); - ProcessList2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/storages/redis/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessList2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/storages/redis/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/storages/redis/\"", + 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); + ProcessList2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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 + (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageRedisClient.Sync.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageRedisClient.Sync.g.cs index dfcffb7..a36c5df 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageRedisClient.Sync.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageRedisClient.Sync.g.cs @@ -14,6 +14,7 @@ public partial class StorageRedisClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,10 +46,12 @@ partial void ProcessSyncResponseContent( /// Sync tasks from a Redis export storage connection. /// /// + /// 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 SyncAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -63,22 +66,43 @@ partial void ProcessSyncResponseContent( securityRequirements: s_SyncSecurityRequirements, operationName: "SyncAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/export/redis/{id}/sync", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/export/redis/{id}/sync", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -88,112 +112,271 @@ partial void ProcessSyncResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareSyncRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareSyncRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessSyncResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync", + methodName: "SyncAsync", + pathTemplate: "$\"/api/storages/export/redis/{id}/sync\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync", + methodName: "SyncAsync", + pathTemplate: "$\"/api/storages/export/redis/{id}/sync\"", + 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); - ProcessSyncResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync", + methodName: "SyncAsync", + pathTemplate: "$\"/api/storages/export/redis/{id}/sync\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.RedisExportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.RedisExportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessSyncResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync", + methodName: "SyncAsync", + pathTemplate: "$\"/api/storages/export/redis/{id}/sync\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync", + methodName: "SyncAsync", + pathTemplate: "$\"/api/storages/export/redis/{id}/sync\"", + 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); + ProcessSyncResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.RedisExportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.RedisExportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageRedisClient.Sync2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageRedisClient.Sync2.g.cs index 9c41ae0..da5c6d9 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageRedisClient.Sync2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageRedisClient.Sync2.g.cs @@ -14,6 +14,7 @@ public partial class StorageRedisClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,10 +46,12 @@ partial void ProcessSync2ResponseContent( /// Sync tasks from a Redis import storage connection. /// /// + /// 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 Sync2Async( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -63,22 +66,43 @@ partial void ProcessSync2ResponseContent( securityRequirements: s_Sync2SecurityRequirements, operationName: "Sync2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/redis/{id}/sync", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/redis/{id}/sync", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -88,112 +112,271 @@ partial void ProcessSync2ResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareSync2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareSync2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessSync2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync2", + methodName: "Sync2Async", + pathTemplate: "$\"/api/storages/redis/{id}/sync\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync2", + methodName: "Sync2Async", + pathTemplate: "$\"/api/storages/redis/{id}/sync\"", + 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); - ProcessSync2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync2", + methodName: "Sync2Async", + pathTemplate: "$\"/api/storages/redis/{id}/sync\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.RedisImportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.RedisImportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessSync2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync2", + methodName: "Sync2Async", + pathTemplate: "$\"/api/storages/redis/{id}/sync\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync2", + methodName: "Sync2Async", + pathTemplate: "$\"/api/storages/redis/{id}/sync\"", + 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); + ProcessSync2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.RedisImportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.RedisImportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageRedisClient.Update.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageRedisClient.Update.g.cs index 74b8e14..91579b2 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageRedisClient.Update.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageRedisClient.Update.g.cs @@ -14,6 +14,7 @@ public partial class StorageRedisClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -48,12 +49,14 @@ partial void ProcessUpdateResponseContent( /// /// /// + /// 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 UpdateAsync( int id, global::LabelStudio.ApiStoragesExportRedisPartialUpdateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -71,22 +74,43 @@ partial void ProcessUpdateResponseContent( securityRequirements: s_UpdateSecurityRequirements, operationName: "UpdateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/export/redis/{id}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/export/redis/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -96,119 +120,278 @@ partial void ProcessUpdateResponseContent( __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); - PrepareUpdateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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::LabelStudio.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); + PrepareUpdateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessUpdateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/storages/export/redis/{id}\"", + 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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/storages/export/redis/{id}\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessUpdateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/storages/export/redis/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.RedisExportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.RedisExportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessUpdateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/storages/export/redis/{id}\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/storages/export/redis/{id}\"", + httpMethod: "PATCH", + 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); + ProcessUpdateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.RedisExportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.RedisExportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 export storage
@@ -243,6 +426,7 @@ partial void ProcessUpdateResponseContent( /// /// Storage title /// + /// 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 UpdateAsync( @@ -256,6 +440,7 @@ partial void ProcessUpdateResponseContent( string? port = default, int? project = default, string? title = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.ApiStoragesExportRedisPartialUpdateRequest @@ -274,6 +459,7 @@ partial void ProcessUpdateResponseContent( return await UpdateAsync( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StorageRedisClient.Update2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageRedisClient.Update2.g.cs index 6bfe456..20cf2e3 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageRedisClient.Update2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageRedisClient.Update2.g.cs @@ -14,6 +14,7 @@ public partial class StorageRedisClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -48,12 +49,14 @@ partial void ProcessUpdate2ResponseContent( ///
/// /// + /// 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 Update2Async( int id, global::LabelStudio.ApiStoragesRedisPartialUpdateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -71,22 +74,43 @@ partial void ProcessUpdate2ResponseContent( securityRequirements: s_Update2SecurityRequirements, operationName: "Update2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/redis/{id}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/redis/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -96,119 +120,278 @@ partial void ProcessUpdate2ResponseContent( __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); - PrepareUpdate2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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::LabelStudio.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); + PrepareUpdate2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessUpdate2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/storages/redis/{id}\"", + 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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/storages/redis/{id}\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessUpdate2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/storages/redis/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.RedisImportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.RedisImportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessUpdate2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/storages/redis/{id}\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/storages/redis/{id}\"", + httpMethod: "PATCH", + 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); + ProcessUpdate2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.RedisImportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.RedisImportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 import storage
@@ -243,6 +426,7 @@ partial void ProcessUpdate2ResponseContent( /// Interpret objects as BLOBs and generate URLs. For example, if your bucket contains images, you can use this option to generate URLs for these images. If set to False, it will read the content of the file and load it into Label Studio.
/// 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 Update2Async( @@ -256,6 +440,7 @@ partial void ProcessUpdate2ResponseContent( string? regexFilter = default, string? title = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.ApiStoragesRedisPartialUpdateRequest @@ -274,6 +459,7 @@ partial void ProcessUpdate2ResponseContent( return await Update2Async( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StorageRedisClient.Validate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageRedisClient.Validate.g.cs index 754dd9b..04b5245 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageRedisClient.Validate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageRedisClient.Validate.g.cs @@ -14,6 +14,7 @@ public partial class StorageRedisClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -40,11 +41,13 @@ partial void ProcessValidateResponse( /// Validate a specific Redis export storage connection. ///
/// + /// 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 ValidateAsync( global::LabelStudio.ApiStoragesExportRedisValidateCreateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -61,22 +64,43 @@ partial void ProcessValidateResponse( securityRequirements: s_ValidateSecurityRequirements, operationName: "ValidateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/storages/export/redis/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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/storages/export/redis/validate", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -86,102 +110,261 @@ partial void ProcessValidateResponse( __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); - PrepareValidateRequest( - 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::LabelStudio.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); + PrepareValidateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessValidateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate", + methodName: "ValidateAsync", + pathTemplate: "\"/api/storages/export/redis/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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate", + methodName: "ValidateAsync", + pathTemplate: "\"/api/storages/export/redis/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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate", + methodName: "ValidateAsync", + pathTemplate: "\"/api/storages/export/redis/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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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) + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessValidateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate", + methodName: "ValidateAsync", + pathTemplate: "\"/api/storages/export/redis/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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate", + methodName: "ValidateAsync", + pathTemplate: "\"/api/storages/export/redis/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); + } + + 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 export storage
@@ -218,6 +401,7 @@ partial void ProcessValidateResponse( /// /// Storage title /// + /// 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 ValidateAsync( @@ -231,6 +415,7 @@ partial void ProcessValidateResponse( string? port = default, int? project = default, string? title = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.ApiStoragesExportRedisValidateCreateRequest @@ -249,6 +434,7 @@ partial void ProcessValidateResponse( await ValidateAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StorageRedisClient.Validate2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageRedisClient.Validate2.g.cs index ca2f832..91f249f 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageRedisClient.Validate2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageRedisClient.Validate2.g.cs @@ -14,6 +14,7 @@ public partial class StorageRedisClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -40,11 +41,13 @@ partial void ProcessValidate2Response( /// Validate a specific Redis import storage connection. ///
/// + /// 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 Validate2Async( global::LabelStudio.ApiStoragesRedisValidateCreateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -61,22 +64,43 @@ partial void ProcessValidate2Response( securityRequirements: s_Validate2SecurityRequirements, operationName: "Validate2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/storages/redis/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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/storages/redis/validate", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -86,102 +110,261 @@ partial void ProcessValidate2Response( __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); - PrepareValidate2Request( - 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::LabelStudio.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); + PrepareValidate2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessValidate2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate2", + methodName: "Validate2Async", + pathTemplate: "\"/api/storages/redis/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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate2", + methodName: "Validate2Async", + pathTemplate: "\"/api/storages/redis/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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate2", + methodName: "Validate2Async", + pathTemplate: "\"/api/storages/redis/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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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) + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessValidate2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate2", + methodName: "Validate2Async", + pathTemplate: "\"/api/storages/redis/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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate2", + methodName: "Validate2Async", + pathTemplate: "\"/api/storages/redis/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); + } + + 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 import storage
@@ -218,6 +401,7 @@ partial void ProcessValidate2Response( /// Interpret objects as BLOBs and generate URLs. For example, if your bucket contains images, you can use this option to generate URLs for these images. If set to False, it will read the content of the file and load it into Label Studio.
/// 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 Validate2Async( @@ -231,6 +415,7 @@ partial void ProcessValidate2Response( string? regexFilter = default, string? title = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.ApiStoragesRedisValidateCreateRequest @@ -249,6 +434,7 @@ partial void ProcessValidate2Response( await Validate2Async( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StorageRedisClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageRedisClient.g.cs index d8df713..41303e7 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageRedisClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageRedisClient.g.cs @@ -30,6 +30,9 @@ public sealed partial class StorageRedisClient : global::LabelStudio.IStorageRed #if DEBUG = true; #endif + + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public StorageRedisClient( 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 StorageRedisClient. + /// 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 StorageRedisClient( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::LabelStudio.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::LabelStudio.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StorageS3Client.Create.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageS3Client.Create.g.cs index e959378..2ecde87 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageS3Client.Create.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageS3Client.Create.g.cs @@ -14,6 +14,7 @@ public partial class StorageS3Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,11 +46,13 @@ partial void ProcessCreateResponseContent( /// Create a new S3 export storage connection to store annotations. ///
/// + /// 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 CreateAsync( global::LabelStudio.ApiStoragesExportS3CreateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -66,22 +69,43 @@ partial void ProcessCreateResponseContent( securityRequirements: s_CreateSecurityRequirements, operationName: "CreateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/storages/export/s3", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/storages/export/s3", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,118 +115,277 @@ partial void ProcessCreateResponseContent( __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::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCreateRequest( - 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); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/storages/export/s3\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/storages/export/s3\"", + 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); - ProcessCreateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/storages/export/s3\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.S3ExportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.S3ExportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessCreateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/storages/export/s3\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/storages/export/s3\"", + 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); + ProcessCreateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.S3ExportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.S3ExportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 export storage
@@ -245,6 +428,7 @@ partial void ProcessCreateResponseContent( /// /// Storage title /// + /// 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 CreateAsync( @@ -260,6 +444,7 @@ partial void ProcessCreateResponseContent( string? regionName = default, string? s3Endpoint = default, string? title = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.ApiStoragesExportS3CreateRequest @@ -280,6 +465,7 @@ partial void ProcessCreateResponseContent( return await CreateAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StorageS3Client.Create2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageS3Client.Create2.g.cs index 184c3f9..a2e2a20 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageS3Client.Create2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageS3Client.Create2.g.cs @@ -14,6 +14,7 @@ public partial class StorageS3Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,11 +46,13 @@ partial void ProcessCreate2ResponseContent( /// Create new S3 import 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 Create2Async( global::LabelStudio.ApiStoragesS3CreateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -66,22 +69,43 @@ partial void ProcessCreate2ResponseContent( securityRequirements: s_Create2SecurityRequirements, operationName: "Create2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/storages/s3/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/storages/s3/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,118 +115,277 @@ partial void ProcessCreate2ResponseContent( __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::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCreate2Request( - 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); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreate2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreate2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "\"/api/storages/s3/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "\"/api/storages/s3/\"", + 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); - ProcessCreate2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "\"/api/storages/s3/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.S3ImportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.S3ImportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessCreate2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "\"/api/storages/s3/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "\"/api/storages/s3/\"", + 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); + ProcessCreate2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.S3ImportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.S3ImportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 new S3 storage
@@ -259,6 +442,7 @@ partial void ProcessCreate2ResponseContent( /// Interpret objects as BLOBs and generate URLs. For example, if your bucket contains images, you can use this option to generate URLs for these images. If set to False, it will read the content of the file and load it into Label Studio.
/// 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 Create2Async( @@ -278,6 +462,7 @@ partial void ProcessCreate2ResponseContent( string? s3Endpoint = default, string? title = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.ApiStoragesS3CreateRequest @@ -302,6 +487,7 @@ partial void ProcessCreate2ResponseContent( return await Create2Async( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StorageS3Client.Delete.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageS3Client.Delete.g.cs index cedac4c..db399ee 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageS3Client.Delete.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageS3Client.Delete.g.cs @@ -14,6 +14,7 @@ public partial class StorageS3Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -40,10 +41,12 @@ partial void ProcessDeleteResponse( /// Delete a specific S3 export storage connection. ///
/// + /// 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 DeleteAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -58,22 +61,43 @@ partial void ProcessDeleteResponse( securityRequirements: s_DeleteSecurityRequirements, operationName: "DeleteAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/export/s3/{id}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/export/s3/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -83,96 +107,255 @@ partial void ProcessDeleteResponse( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDeleteRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDeleteRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/storages/export/s3/{id}\"", + 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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/storages/export/s3/{id}\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessDeleteResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/storages/export/s3/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessDeleteResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/storages/export/s3/{id}\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/storages/export/s3/{id}\"", + httpMethod: "DELETE", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageS3Client.Delete2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageS3Client.Delete2.g.cs index 49d1d73..0af3973 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageS3Client.Delete2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageS3Client.Delete2.g.cs @@ -14,6 +14,7 @@ public partial class StorageS3Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -40,10 +41,12 @@ partial void ProcessDelete2Response( /// Delete a specific S3 import storage connection. /// /// + /// 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 Delete2Async( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -58,22 +61,43 @@ partial void ProcessDelete2Response( securityRequirements: s_Delete2SecurityRequirements, operationName: "Delete2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/s3/{id}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/s3/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -83,96 +107,255 @@ partial void ProcessDelete2Response( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDelete2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDelete2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/storages/s3/{id}\"", + 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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/storages/s3/{id}\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessDelete2Response( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/storages/s3/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessDelete2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/storages/s3/{id}\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/storages/s3/{id}\"", + httpMethod: "DELETE", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageS3Client.Get.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageS3Client.Get.g.cs index b353992..5d28aa7 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageS3Client.Get.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageS3Client.Get.g.cs @@ -14,6 +14,7 @@ public partial class StorageS3Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,10 +46,12 @@ partial void ProcessGetResponseContent( /// Get a specific S3 export storage connection. /// /// + /// 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 GetAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -63,22 +66,43 @@ partial void ProcessGetResponseContent( securityRequirements: s_GetSecurityRequirements, operationName: "GetAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/export/s3/{id}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/export/s3/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -88,112 +112,271 @@ partial void ProcessGetResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/storages/export/s3/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/storages/export/s3/{id}\"", + 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); - ProcessGetResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/storages/export/s3/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.S3ExportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.S3ExportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGetResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/storages/export/s3/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/storages/export/s3/{id}\"", + 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); + ProcessGetResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.S3ExportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.S3ExportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageS3Client.Get2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageS3Client.Get2.g.cs index 0de357e..cb8c5cd 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageS3Client.Get2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageS3Client.Get2.g.cs @@ -14,6 +14,7 @@ public partial class StorageS3Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,10 +46,12 @@ partial void ProcessGet2ResponseContent( /// Get a specific S3 import storage connection. /// /// + /// 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 Get2Async( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -63,22 +66,43 @@ partial void ProcessGet2ResponseContent( securityRequirements: s_Get2SecurityRequirements, operationName: "Get2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/s3/{id}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/s3/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -88,112 +112,271 @@ partial void ProcessGet2ResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGet2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGet2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGet2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "$\"/api/storages/s3/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "$\"/api/storages/s3/{id}\"", + 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); - ProcessGet2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "$\"/api/storages/s3/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.S3ImportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.S3ImportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGet2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "$\"/api/storages/s3/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "$\"/api/storages/s3/{id}\"", + 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); + ProcessGet2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.S3ImportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.S3ImportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageS3Client.List.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageS3Client.List.g.cs index c84fa8a..8a2b6a7 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageS3Client.List.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageS3Client.List.g.cs @@ -14,6 +14,7 @@ public partial class StorageS3Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -48,11 +49,13 @@ partial void ProcessListResponseContent( /// /// /// + /// 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> ListAsync( int project, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -68,26 +71,47 @@ partial void ProcessListResponseContent( securityRequirements: s_ListSecurityRequirements, operationName: "ListAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/storages/export/s3", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("ordering", ordering) - .AddRequiredParameter("project", project.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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/storages/export/s3", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("ordering", ordering) + .AddRequiredParameter("project", project.ToString()!) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -97,113 +121,272 @@ partial void ProcessListResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareListRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - ordering: ordering, - project: project); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareListRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + ordering: ordering, + project: project); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessListResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/storages/export/s3\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/storages/export/s3\"", + 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); - ProcessListResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/storages/export/s3\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessListResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/storages/export/s3\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/storages/export/s3\"", + 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); + ProcessListResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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 + (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageS3Client.List2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageS3Client.List2.g.cs index d44f836..5610f82 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageS3Client.List2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageS3Client.List2.g.cs @@ -14,6 +14,7 @@ public partial class StorageS3Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -48,11 +49,13 @@ partial void ProcessList2ResponseContent( /// /// /// + /// 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> List2Async( int project, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -68,26 +71,47 @@ partial void ProcessList2ResponseContent( securityRequirements: s_List2SecurityRequirements, operationName: "List2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/storages/s3/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("ordering", ordering) - .AddRequiredParameter("project", project.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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/storages/s3/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("ordering", ordering) + .AddRequiredParameter("project", project.ToString()!) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -97,113 +121,272 @@ partial void ProcessList2ResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareList2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - ordering: ordering, - project: project); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareList2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + ordering: ordering, + project: project); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessList2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/storages/s3/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/storages/s3/\"", + 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); - ProcessList2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/storages/s3/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessList2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/storages/s3/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/storages/s3/\"", + 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); + ProcessList2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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 + (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageS3Client.Sync.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageS3Client.Sync.g.cs index ae1e9ac..207bb09 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageS3Client.Sync.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageS3Client.Sync.g.cs @@ -14,6 +14,7 @@ public partial class StorageS3Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,10 +46,12 @@ partial void ProcessSyncResponseContent( /// Sync tasks from an S3 export storage connection. /// /// + /// 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 SyncAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -63,22 +66,43 @@ partial void ProcessSyncResponseContent( securityRequirements: s_SyncSecurityRequirements, operationName: "SyncAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/export/s3/{id}/sync", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/export/s3/{id}/sync", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -88,112 +112,271 @@ partial void ProcessSyncResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareSyncRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareSyncRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessSyncResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync", + methodName: "SyncAsync", + pathTemplate: "$\"/api/storages/export/s3/{id}/sync\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync", + methodName: "SyncAsync", + pathTemplate: "$\"/api/storages/export/s3/{id}/sync\"", + 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); - ProcessSyncResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync", + methodName: "SyncAsync", + pathTemplate: "$\"/api/storages/export/s3/{id}/sync\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.S3ExportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.S3ExportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessSyncResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync", + methodName: "SyncAsync", + pathTemplate: "$\"/api/storages/export/s3/{id}/sync\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync", + methodName: "SyncAsync", + pathTemplate: "$\"/api/storages/export/s3/{id}/sync\"", + 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); + ProcessSyncResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.S3ExportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.S3ExportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageS3Client.Sync2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageS3Client.Sync2.g.cs index a530277..18e72c8 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageS3Client.Sync2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageS3Client.Sync2.g.cs @@ -14,6 +14,7 @@ public partial class StorageS3Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,10 +46,12 @@ partial void ProcessSync2ResponseContent( /// Sync tasks from an S3 import storage connection. /// /// + /// 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 Sync2Async( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -63,22 +66,43 @@ partial void ProcessSync2ResponseContent( securityRequirements: s_Sync2SecurityRequirements, operationName: "Sync2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/s3/{id}/sync", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/s3/{id}/sync", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -88,112 +112,271 @@ partial void ProcessSync2ResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareSync2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareSync2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessSync2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync2", + methodName: "Sync2Async", + pathTemplate: "$\"/api/storages/s3/{id}/sync\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync2", + methodName: "Sync2Async", + pathTemplate: "$\"/api/storages/s3/{id}/sync\"", + 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); - ProcessSync2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync2", + methodName: "Sync2Async", + pathTemplate: "$\"/api/storages/s3/{id}/sync\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.S3ImportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.S3ImportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessSync2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync2", + methodName: "Sync2Async", + pathTemplate: "$\"/api/storages/s3/{id}/sync\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync2", + methodName: "Sync2Async", + pathTemplate: "$\"/api/storages/s3/{id}/sync\"", + 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); + ProcessSync2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.S3ImportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.S3ImportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageS3Client.Update.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageS3Client.Update.g.cs index 671c9cd..7bf3c5f 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageS3Client.Update.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageS3Client.Update.g.cs @@ -14,6 +14,7 @@ public partial class StorageS3Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -48,12 +49,14 @@ partial void ProcessUpdateResponseContent( /// /// /// + /// 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 UpdateAsync( int id, global::LabelStudio.ApiStoragesExportS3PartialUpdateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -71,22 +74,43 @@ partial void ProcessUpdateResponseContent( securityRequirements: s_UpdateSecurityRequirements, operationName: "UpdateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/export/s3/{id}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/export/s3/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -96,119 +120,278 @@ partial void ProcessUpdateResponseContent( __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); - PrepareUpdateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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::LabelStudio.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); + PrepareUpdateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessUpdateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/storages/export/s3/{id}\"", + 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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/storages/export/s3/{id}\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessUpdateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/storages/export/s3/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.S3ExportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.S3ExportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessUpdateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/storages/export/s3/{id}\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/storages/export/s3/{id}\"", + httpMethod: "PATCH", + 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); + ProcessUpdateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.S3ExportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.S3ExportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 export storage
@@ -252,6 +435,7 @@ partial void ProcessUpdateResponseContent( /// /// Storage title /// + /// 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 UpdateAsync( @@ -268,6 +452,7 @@ partial void ProcessUpdateResponseContent( string? regionName = default, string? s3Endpoint = default, string? title = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.ApiStoragesExportS3PartialUpdateRequest @@ -289,6 +474,7 @@ partial void ProcessUpdateResponseContent( return await UpdateAsync( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StorageS3Client.Update2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageS3Client.Update2.g.cs index 1afe8a8..e087fbb 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageS3Client.Update2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageS3Client.Update2.g.cs @@ -14,6 +14,7 @@ public partial class StorageS3Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -48,12 +49,14 @@ partial void ProcessUpdate2ResponseContent( ///
/// /// + /// 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 Update2Async( int id, global::LabelStudio.ApiStoragesS3PartialUpdateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -71,22 +74,43 @@ partial void ProcessUpdate2ResponseContent( securityRequirements: s_Update2SecurityRequirements, operationName: "Update2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/s3/{id}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/s3/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -96,119 +120,278 @@ partial void ProcessUpdate2ResponseContent( __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); - PrepareUpdate2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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::LabelStudio.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); + PrepareUpdate2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessUpdate2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/storages/s3/{id}\"", + 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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/storages/s3/{id}\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessUpdate2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/storages/s3/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.S3ImportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.S3ImportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessUpdate2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/storages/s3/{id}\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/storages/s3/{id}\"", + httpMethod: "PATCH", + 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); + ProcessUpdate2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.S3ImportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.S3ImportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 import storage
@@ -266,6 +449,7 @@ partial void ProcessUpdate2ResponseContent( /// Interpret objects as BLOBs and generate URLs. For example, if your bucket contains images, you can use this option to generate URLs for these images. If set to False, it will read the content of the file and load it into Label Studio.
/// 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 Update2Async( @@ -286,6 +470,7 @@ partial void ProcessUpdate2ResponseContent( string? s3Endpoint = default, string? title = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.ApiStoragesS3PartialUpdateRequest @@ -311,6 +496,7 @@ partial void ProcessUpdate2ResponseContent( return await Update2Async( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StorageS3Client.Validate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageS3Client.Validate.g.cs index 3dbf280..3f2bb41 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageS3Client.Validate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageS3Client.Validate.g.cs @@ -14,6 +14,7 @@ public partial class StorageS3Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -40,11 +41,13 @@ partial void ProcessValidateResponse( /// Validate a specific S3 export storage connection. ///
/// + /// 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 ValidateAsync( global::LabelStudio.ApiStoragesExportS3ValidateCreateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -61,22 +64,43 @@ partial void ProcessValidateResponse( securityRequirements: s_ValidateSecurityRequirements, operationName: "ValidateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/storages/export/s3/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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/storages/export/s3/validate", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -86,102 +110,261 @@ partial void ProcessValidateResponse( __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::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareValidateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - request: request); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareValidateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate", + methodName: "ValidateAsync", + pathTemplate: "\"/api/storages/export/s3/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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate", + methodName: "ValidateAsync", + pathTemplate: "\"/api/storages/export/s3/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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessValidateResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate", + methodName: "ValidateAsync", + pathTemplate: "\"/api/storages/export/s3/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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessValidateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate", + methodName: "ValidateAsync", + pathTemplate: "\"/api/storages/export/s3/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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate", + methodName: "ValidateAsync", + pathTemplate: "\"/api/storages/export/s3/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); + } + + 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 export storage
@@ -227,6 +410,7 @@ partial void ProcessValidateResponse( /// /// Storage title /// + /// 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 ValidateAsync( @@ -243,6 +427,7 @@ partial void ProcessValidateResponse( string? regionName = default, string? s3Endpoint = default, string? title = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.ApiStoragesExportS3ValidateCreateRequest @@ -264,6 +449,7 @@ partial void ProcessValidateResponse( await ValidateAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StorageS3Client.Validate2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageS3Client.Validate2.g.cs index c8f2af1..2a11c0c 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageS3Client.Validate2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageS3Client.Validate2.g.cs @@ -14,6 +14,7 @@ public partial class StorageS3Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -40,11 +41,13 @@ partial void ProcessValidate2Response( /// Validate a specific S3 import storage connection. ///
/// + /// 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 Validate2Async( global::LabelStudio.ApiStoragesS3ValidateCreateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -61,22 +64,43 @@ partial void ProcessValidate2Response( securityRequirements: s_Validate2SecurityRequirements, operationName: "Validate2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/storages/s3/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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/storages/s3/validate", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -86,102 +110,261 @@ partial void ProcessValidate2Response( __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::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareValidate2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - request: request); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareValidate2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate2", + methodName: "Validate2Async", + pathTemplate: "\"/api/storages/s3/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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate2", + methodName: "Validate2Async", + pathTemplate: "\"/api/storages/s3/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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessValidate2Response( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate2", + methodName: "Validate2Async", + pathTemplate: "\"/api/storages/s3/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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessValidate2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate2", + methodName: "Validate2Async", + pathTemplate: "\"/api/storages/s3/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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate2", + methodName: "Validate2Async", + pathTemplate: "\"/api/storages/s3/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); + } + + 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 import storage
@@ -241,6 +424,7 @@ partial void ProcessValidate2Response( /// Interpret objects as BLOBs and generate URLs. For example, if your bucket contains images, you can use this option to generate URLs for these images. If set to False, it will read the content of the file and load it into Label Studio.
/// 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 Validate2Async( @@ -261,6 +445,7 @@ partial void ProcessValidate2Response( string? s3Endpoint = default, string? title = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.ApiStoragesS3ValidateCreateRequest @@ -286,6 +471,7 @@ partial void ProcessValidate2Response( await Validate2Async( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StorageS3Client.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageS3Client.g.cs index 1c4d69a..6eb7325 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageS3Client.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageS3Client.g.cs @@ -30,6 +30,9 @@ public sealed partial class StorageS3Client : global::LabelStudio.IStorageS3Clie #if DEBUG = true; #endif + + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public StorageS3Client( 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 StorageS3Client. + /// 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 StorageS3Client( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::LabelStudio.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::LabelStudio.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StorageS3RolesClient.Create.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageS3RolesClient.Create.g.cs index 269a030..e3f848c 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageS3RolesClient.Create.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageS3RolesClient.Create.g.cs @@ -14,6 +14,7 @@ public partial class StorageS3RolesClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,11 +52,13 @@ partial void ProcessCreateResponseContent( /// Create an S3 export storage connection with IAM role access to store annotations. ///
/// + /// 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 CreateAsync( global::LabelStudio.LseS3ExportStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -72,22 +75,43 @@ partial void ProcessCreateResponseContent( securityRequirements: s_CreateSecurityRequirements, operationName: "CreateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/storages/export/s3s", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/storages/export/s3s", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -97,118 +121,277 @@ partial void ProcessCreateResponseContent( __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::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCreateRequest( - 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); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/storages/export/s3s\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/storages/export/s3s\"", + 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); - ProcessCreateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/storages/export/s3s\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.LseS3ExportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.LseS3ExportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessCreateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/storages/export/s3s\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/storages/export/s3s\"", + 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); + ProcessCreateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.LseS3ExportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.LseS3ExportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 export storage
@@ -295,6 +478,7 @@ partial void ProcessCreateResponseContent( /// /// Interpret objects as BLOBs and generate URLs /// + /// 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 CreateAsync( @@ -322,6 +506,7 @@ partial void ProcessCreateResponseContent( string? title = default, string? traceback = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.LseS3ExportStorageRequest @@ -354,6 +539,7 @@ partial void ProcessCreateResponseContent( return await CreateAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StorageS3RolesClient.Create2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageS3RolesClient.Create2.g.cs index 4628ee9..309c715 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageS3RolesClient.Create2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageS3RolesClient.Create2.g.cs @@ -14,6 +14,7 @@ public partial class StorageS3RolesClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,11 +52,13 @@ partial void ProcessCreate2ResponseContent( /// Create S3 import storage with IAM role access. ///
/// + /// 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 Create2Async( global::LabelStudio.LseS3ImportStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -72,22 +75,43 @@ partial void ProcessCreate2ResponseContent( securityRequirements: s_Create2SecurityRequirements, operationName: "Create2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/storages/s3s/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/storages/s3s/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -97,118 +121,277 @@ partial void ProcessCreate2ResponseContent( __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::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCreate2Request( - 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); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreate2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreate2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "\"/api/storages/s3s/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "\"/api/storages/s3s/\"", + 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); - ProcessCreate2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "\"/api/storages/s3s/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.LseS3ImportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.LseS3ImportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessCreate2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "\"/api/storages/s3s/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "\"/api/storages/s3s/\"", + 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); + ProcessCreate2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.LseS3ImportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.LseS3ImportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 import storage
@@ -301,6 +484,7 @@ partial void ProcessCreate2ResponseContent( /// /// Interpret objects as BLOBs and generate URLs /// + /// 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 Create2Async( @@ -330,6 +514,7 @@ partial void ProcessCreate2ResponseContent( string? title = default, string? traceback = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.LseS3ImportStorageRequest @@ -364,6 +549,7 @@ partial void ProcessCreate2ResponseContent( return await Create2Async( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StorageS3RolesClient.Delete.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageS3RolesClient.Delete.g.cs index 17dee1b..80336c4 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageS3RolesClient.Delete.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageS3RolesClient.Delete.g.cs @@ -14,6 +14,7 @@ public partial class StorageS3RolesClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -46,10 +47,12 @@ partial void ProcessDeleteResponse( /// Delete a specific S3 export storage connection that was set up with IAM role access. ///
/// + /// 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 DeleteAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -64,22 +67,43 @@ partial void ProcessDeleteResponse( securityRequirements: s_DeleteSecurityRequirements, operationName: "DeleteAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/export/s3s/{id}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/export/s3s/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -89,96 +113,255 @@ partial void ProcessDeleteResponse( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDeleteRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDeleteRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/storages/export/s3s/{id}\"", + 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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/storages/export/s3s/{id}\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessDeleteResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/storages/export/s3s/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessDeleteResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/storages/export/s3s/{id}\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/storages/export/s3s/{id}\"", + httpMethod: "DELETE", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageS3RolesClient.Delete2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageS3RolesClient.Delete2.g.cs index 026d8c6..d0a7340 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageS3RolesClient.Delete2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageS3RolesClient.Delete2.g.cs @@ -14,6 +14,7 @@ public partial class StorageS3RolesClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -46,10 +47,12 @@ partial void ProcessDelete2Response( /// Delete a specific S3 import storage connection that was set up with IAM role access. /// /// + /// 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 Delete2Async( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -64,22 +67,43 @@ partial void ProcessDelete2Response( securityRequirements: s_Delete2SecurityRequirements, operationName: "Delete2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/s3s/{id}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/s3s/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -89,96 +113,255 @@ partial void ProcessDelete2Response( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDelete2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDelete2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/storages/s3s/{id}\"", + 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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/storages/s3s/{id}\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessDelete2Response( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/storages/s3s/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessDelete2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/storages/s3s/{id}\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/storages/s3s/{id}\"", + httpMethod: "DELETE", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageS3RolesClient.Get.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageS3RolesClient.Get.g.cs index ec45aa4..e7bb8b2 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageS3RolesClient.Get.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageS3RolesClient.Get.g.cs @@ -14,6 +14,7 @@ public partial class StorageS3RolesClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,10 +52,12 @@ partial void ProcessGetResponseContent( /// Get a specific S3 export storage connection that was set up with IAM role access. /// /// + /// 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 GetAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -69,22 +72,43 @@ partial void ProcessGetResponseContent( securityRequirements: s_GetSecurityRequirements, operationName: "GetAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/export/s3s/{id}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/export/s3s/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,112 +118,271 @@ partial void ProcessGetResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/storages/export/s3s/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/storages/export/s3s/{id}\"", + 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); - ProcessGetResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/storages/export/s3s/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.LseS3ExportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.LseS3ExportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGetResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/storages/export/s3s/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/storages/export/s3s/{id}\"", + 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); + ProcessGetResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.LseS3ExportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.LseS3ExportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageS3RolesClient.Get2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageS3RolesClient.Get2.g.cs index 09a1a57..509780c 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageS3RolesClient.Get2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageS3RolesClient.Get2.g.cs @@ -14,6 +14,7 @@ public partial class StorageS3RolesClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,10 +52,12 @@ partial void ProcessGet2ResponseContent( /// Get a specific S3 import storage connection that was set up with IAM role access. /// /// + /// 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 Get2Async( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -69,22 +72,43 @@ partial void ProcessGet2ResponseContent( securityRequirements: s_Get2SecurityRequirements, operationName: "Get2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/s3s/{id}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/s3s/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,112 +118,271 @@ partial void ProcessGet2ResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGet2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGet2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGet2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "$\"/api/storages/s3s/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "$\"/api/storages/s3s/{id}\"", + 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); - ProcessGet2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "$\"/api/storages/s3s/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.LseS3ImportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.LseS3ImportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGet2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "$\"/api/storages/s3s/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get2", + methodName: "Get2Async", + pathTemplate: "$\"/api/storages/s3s/{id}\"", + 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); + ProcessGet2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.LseS3ImportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.LseS3ImportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageS3RolesClient.List.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageS3RolesClient.List.g.cs index 96ee2ab..9fd15e9 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageS3RolesClient.List.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageS3RolesClient.List.g.cs @@ -14,6 +14,7 @@ public partial class StorageS3RolesClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -54,11 +55,13 @@ partial void ProcessListResponseContent( /// /// /// + /// 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> ListAsync( int project, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -74,26 +77,47 @@ partial void ProcessListResponseContent( securityRequirements: s_ListSecurityRequirements, operationName: "ListAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/storages/export/s3s", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("ordering", ordering) - .AddRequiredParameter("project", project.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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/storages/export/s3s", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("ordering", ordering) + .AddRequiredParameter("project", project.ToString()!) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -103,113 +127,272 @@ partial void ProcessListResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareListRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - ordering: ordering, - project: project); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareListRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + ordering: ordering, + project: project); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessListResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/storages/export/s3s\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/storages/export/s3s\"", + 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); - ProcessListResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/storages/export/s3s\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessListResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/storages/export/s3s\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/storages/export/s3s\"", + 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); + ProcessListResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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 + (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageS3RolesClient.List2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageS3RolesClient.List2.g.cs index 572168a..896a854 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageS3RolesClient.List2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageS3RolesClient.List2.g.cs @@ -14,6 +14,7 @@ public partial class StorageS3RolesClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -54,11 +55,13 @@ partial void ProcessList2ResponseContent( /// /// /// + /// 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> List2Async( int project, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -74,26 +77,47 @@ partial void ProcessList2ResponseContent( securityRequirements: s_List2SecurityRequirements, operationName: "List2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/storages/s3s/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("ordering", ordering) - .AddRequiredParameter("project", project.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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/storages/s3s/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("ordering", ordering) + .AddRequiredParameter("project", project.ToString()!) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -103,113 +127,272 @@ partial void ProcessList2ResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareList2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - ordering: ordering, - project: project); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareList2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + ordering: ordering, + project: project); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessList2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/storages/s3s/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/storages/s3s/\"", + 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); - ProcessList2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/storages/s3s/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessList2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/storages/s3s/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/storages/s3s/\"", + 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); + ProcessList2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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 + (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageS3RolesClient.Sync.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageS3RolesClient.Sync.g.cs index 98a0fb0..f1d02e7 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageS3RolesClient.Sync.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageS3RolesClient.Sync.g.cs @@ -14,6 +14,7 @@ public partial class StorageS3RolesClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,10 +52,12 @@ partial void ProcessSyncResponseContent( /// Sync tasks from an S3 export 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 SyncAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -69,22 +72,43 @@ partial void ProcessSyncResponseContent( securityRequirements: s_SyncSecurityRequirements, operationName: "SyncAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/export/s3s/{id}/sync", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/export/s3s/{id}/sync", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,112 +118,271 @@ partial void ProcessSyncResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareSyncRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareSyncRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessSyncResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync", + methodName: "SyncAsync", + pathTemplate: "$\"/api/storages/export/s3s/{id}/sync\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync", + methodName: "SyncAsync", + pathTemplate: "$\"/api/storages/export/s3s/{id}/sync\"", + 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); - ProcessSyncResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync", + methodName: "SyncAsync", + pathTemplate: "$\"/api/storages/export/s3s/{id}/sync\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.LseS3ExportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.LseS3ExportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessSyncResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync", + methodName: "SyncAsync", + pathTemplate: "$\"/api/storages/export/s3s/{id}/sync\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync", + methodName: "SyncAsync", + pathTemplate: "$\"/api/storages/export/s3s/{id}/sync\"", + 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); + ProcessSyncResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.LseS3ExportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.LseS3ExportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageS3RolesClient.Sync2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageS3RolesClient.Sync2.g.cs index bb3cd82..39782c8 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageS3RolesClient.Sync2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageS3RolesClient.Sync2.g.cs @@ -14,6 +14,7 @@ public partial class StorageS3RolesClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,10 +52,12 @@ partial void ProcessSync2ResponseContent( /// Sync tasks from an S3 import storage connection that was set up with IAM role access. /// /// + /// 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 Sync2Async( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -69,22 +72,43 @@ partial void ProcessSync2ResponseContent( securityRequirements: s_Sync2SecurityRequirements, operationName: "Sync2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/s3s/{id}/sync", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/s3s/{id}/sync", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,112 +118,271 @@ partial void ProcessSync2ResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareSync2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareSync2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessSync2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync2", + methodName: "Sync2Async", + pathTemplate: "$\"/api/storages/s3s/{id}/sync\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync2", + methodName: "Sync2Async", + pathTemplate: "$\"/api/storages/s3s/{id}/sync\"", + 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); - ProcessSync2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync2", + methodName: "Sync2Async", + pathTemplate: "$\"/api/storages/s3s/{id}/sync\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.LseS3ImportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.LseS3ImportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessSync2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync2", + methodName: "Sync2Async", + pathTemplate: "$\"/api/storages/s3s/{id}/sync\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sync2", + methodName: "Sync2Async", + pathTemplate: "$\"/api/storages/s3s/{id}/sync\"", + 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); + ProcessSync2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.LseS3ImportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.LseS3ImportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.StorageS3RolesClient.Update.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageS3RolesClient.Update.g.cs index 52b18a3..4eb333b 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageS3RolesClient.Update.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageS3RolesClient.Update.g.cs @@ -14,6 +14,7 @@ public partial class StorageS3RolesClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -54,12 +55,14 @@ partial void ProcessUpdateResponseContent( /// /// /// + /// 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 UpdateAsync( int id, global::LabelStudio.PatchedLseS3ExportStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -77,22 +80,43 @@ partial void ProcessUpdateResponseContent( securityRequirements: s_UpdateSecurityRequirements, operationName: "UpdateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/export/s3s/{id}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/export/s3s/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -102,119 +126,278 @@ partial void ProcessUpdateResponseContent( __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); - PrepareUpdateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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::LabelStudio.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); + PrepareUpdateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessUpdateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/storages/export/s3s/{id}\"", + 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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/storages/export/s3s/{id}\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessUpdateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/storages/export/s3s/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.LseS3ExportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.LseS3ExportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessUpdateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/storages/export/s3s/{id}\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/storages/export/s3s/{id}\"", + httpMethod: "PATCH", + 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); + ProcessUpdateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.LseS3ExportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.LseS3ExportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 export storage
@@ -302,6 +485,7 @@ partial void ProcessUpdateResponseContent( /// /// Interpret objects as BLOBs and generate URLs /// + /// 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 UpdateAsync( @@ -330,6 +514,7 @@ partial void ProcessUpdateResponseContent( string? title = default, string? traceback = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.PatchedLseS3ExportStorageRequest @@ -363,6 +548,7 @@ partial void ProcessUpdateResponseContent( return await UpdateAsync( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StorageS3RolesClient.Update2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageS3RolesClient.Update2.g.cs index 01ed827..149be19 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageS3RolesClient.Update2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageS3RolesClient.Update2.g.cs @@ -14,6 +14,7 @@ public partial class StorageS3RolesClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -54,12 +55,14 @@ partial void ProcessUpdate2ResponseContent( ///
/// /// + /// 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 Update2Async( int id, global::LabelStudio.PatchedLseS3ImportStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -77,22 +80,43 @@ partial void ProcessUpdate2ResponseContent( securityRequirements: s_Update2SecurityRequirements, operationName: "Update2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/storages/s3s/{id}", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/storages/s3s/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -102,119 +126,278 @@ partial void ProcessUpdate2ResponseContent( __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); - PrepareUpdate2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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::LabelStudio.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); + PrepareUpdate2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessUpdate2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/storages/s3s/{id}\"", + 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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/storages/s3s/{id}\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessUpdate2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/storages/s3s/{id}\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.LseS3ImportStorage.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.LseS3ImportStorage.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessUpdate2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/storages/s3s/{id}\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/storages/s3s/{id}\"", + httpMethod: "PATCH", + 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); + ProcessUpdate2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.LseS3ImportStorage.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.LseS3ImportStorage.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 import storage
@@ -308,6 +491,7 @@ partial void ProcessUpdate2ResponseContent( /// /// Interpret objects as BLOBs and generate URLs /// + /// 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 Update2Async( @@ -338,6 +522,7 @@ partial void ProcessUpdate2ResponseContent( string? title = default, string? traceback = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.PatchedLseS3ImportStorageRequest @@ -373,6 +558,7 @@ partial void ProcessUpdate2ResponseContent( return await Update2Async( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StorageS3RolesClient.Validate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageS3RolesClient.Validate.g.cs index 2598bc9..d4e2563 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageS3RolesClient.Validate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageS3RolesClient.Validate.g.cs @@ -14,6 +14,7 @@ public partial class StorageS3RolesClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -46,11 +47,13 @@ partial void ProcessValidateResponse( /// Validate a specific S3 export storage connection that was set up with IAM role access. ///
/// + /// 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 ValidateAsync( global::LabelStudio.LseS3ExportStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -67,22 +70,43 @@ partial void ProcessValidateResponse( securityRequirements: s_ValidateSecurityRequirements, operationName: "ValidateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/storages/export/s3s/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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/storages/export/s3s/validate", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -92,102 +116,261 @@ partial void ProcessValidateResponse( __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::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareValidateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - request: request); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareValidateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate", + methodName: "ValidateAsync", + pathTemplate: "\"/api/storages/export/s3s/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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate", + methodName: "ValidateAsync", + pathTemplate: "\"/api/storages/export/s3s/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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessValidateResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate", + methodName: "ValidateAsync", + pathTemplate: "\"/api/storages/export/s3s/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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessValidateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate", + methodName: "ValidateAsync", + pathTemplate: "\"/api/storages/export/s3s/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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate", + methodName: "ValidateAsync", + pathTemplate: "\"/api/storages/export/s3s/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); + } + + 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 export storage
@@ -274,6 +457,7 @@ partial void ProcessValidateResponse( /// /// Interpret objects as BLOBs and generate URLs /// + /// 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 ValidateAsync( @@ -301,6 +485,7 @@ partial void ProcessValidateResponse( string? title = default, string? traceback = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.LseS3ExportStorageRequest @@ -333,6 +518,7 @@ partial void ProcessValidateResponse( await ValidateAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StorageS3RolesClient.Validate2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageS3RolesClient.Validate2.g.cs index 4e930c8..7ae9340 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageS3RolesClient.Validate2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageS3RolesClient.Validate2.g.cs @@ -14,6 +14,7 @@ public partial class StorageS3RolesClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -46,11 +47,13 @@ partial void ProcessValidate2Response( /// Validate a specific S3 import storage connection that was set up with IAM role access. ///
/// + /// 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 Validate2Async( global::LabelStudio.LseS3ImportStorageRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -67,22 +70,43 @@ partial void ProcessValidate2Response( securityRequirements: s_Validate2SecurityRequirements, operationName: "Validate2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/storages/s3s/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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/storages/s3s/validate", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -92,102 +116,261 @@ partial void ProcessValidate2Response( __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::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareValidate2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - request: request); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareValidate2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate2", + methodName: "Validate2Async", + pathTemplate: "\"/api/storages/s3s/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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate2", + methodName: "Validate2Async", + pathTemplate: "\"/api/storages/s3s/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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessValidate2Response( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate2", + methodName: "Validate2Async", + pathTemplate: "\"/api/storages/s3s/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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessValidate2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate2", + methodName: "Validate2Async", + pathTemplate: "\"/api/storages/s3s/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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Validate2", + methodName: "Validate2Async", + pathTemplate: "\"/api/storages/s3s/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); + } + + 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 import storage
@@ -280,6 +463,7 @@ partial void ProcessValidate2Response( /// /// Interpret objects as BLOBs and generate URLs /// + /// 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 Validate2Async( @@ -309,6 +493,7 @@ partial void ProcessValidate2Response( string? title = default, string? traceback = default, bool? useBlobUrls = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.LseS3ImportStorageRequest @@ -343,6 +528,7 @@ partial void ProcessValidate2Response( await Validate2Async( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.StorageS3RolesClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.StorageS3RolesClient.g.cs index ba2e597..631daf8 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.StorageS3RolesClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.StorageS3RolesClient.g.cs @@ -30,6 +30,9 @@ public sealed partial class StorageS3RolesClient : global::LabelStudio.IStorageS #if DEBUG = true; #endif + + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public StorageS3RolesClient( 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 StorageS3RolesClient. + /// 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 StorageS3RolesClient( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::LabelStudio.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::LabelStudio.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/LabelStudio/Generated/LabelStudio.Tasks2Client.Create.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Tasks2Client.Create.g.cs index 7434626..cad0163 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Tasks2Client.Create.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Tasks2Client.Create.g.cs @@ -14,6 +14,7 @@ public partial class Tasks2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,11 +46,13 @@ partial void ProcessCreateResponseContent( /// Create a new task ///
/// + /// 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 CreateAsync( global::LabelStudio.LseTaskRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -66,22 +69,43 @@ partial void ProcessCreateResponseContent( securityRequirements: s_CreateSecurityRequirements, operationName: "CreateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/tasks/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/tasks/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,118 +115,277 @@ partial void ProcessCreateResponseContent( __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::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCreateRequest( - 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); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/tasks/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/tasks/\"", + 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); - ProcessCreateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/tasks/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.LseTask.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.LseTask.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessCreateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/tasks/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/tasks/\"", + 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); + ProcessCreateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.LseTask.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.LseTask.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 task
@@ -256,6 +439,7 @@ partial void ProcessCreateResponseContent( /// /// Last annotator or reviewer who updated this task /// + /// 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 CreateAsync( @@ -275,6 +459,7 @@ partial void ProcessCreateResponseContent( int? totalPredictions = default, int? unresolvedCommentCount = default, int? updatedBy = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.LseTaskRequest @@ -299,6 +484,7 @@ partial void ProcessCreateResponseContent( return await CreateAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.Tasks2Client.CreateEvent.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Tasks2Client.CreateEvent.g.cs index 6112c46..5518c13 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Tasks2Client.CreateEvent.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Tasks2Client.CreateEvent.g.cs @@ -14,6 +14,7 @@ public partial class Tasks2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -85,12 +86,14 @@ partial void ProcessCreateEventResponseContent( ///
/// /// + /// 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 CreateEventAsync( int id, global::LabelStudio.TaskEventRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -108,22 +111,43 @@ partial void ProcessCreateEventResponseContent( securityRequirements: s_CreateEventSecurityRequirements, operationName: "CreateEventAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/tasks/{id}/events/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/tasks/{id}/events/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -133,251 +157,410 @@ partial void ProcessCreateEventResponseContent( __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); - PrepareCreateEventRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - request: request); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + 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::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreateEventResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // - if ((int)__response.StatusCode == 400) - { - string? __content_400 = null; - global::System.Exception? __exception_400 = null; - try - { - if (ReadResponseAsString) - { - __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - } - else - { - __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - } - } - catch (global::System.Exception __ex) - { - __exception_400 = __ex; - } + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreateEventRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - throw new global::LabelStudio.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), - }; + return __httpRequest; } - // - if ((int)__response.StatusCode == 401) + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_401 = null; - global::System.Exception? __exception_401 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateEvent", + methodName: "CreateEventAsync", + pathTemplate: "$\"/api/tasks/{id}/events/\"", + 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_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + __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_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - } - } - catch (global::System.Exception __ex) - { - __exception_401 = __ex; - } + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateEvent", + methodName: "CreateEventAsync", + pathTemplate: "$\"/api/tasks/{id}/events/\"", + 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; + } - throw new global::LabelStudio.ApiException( - message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_401, - statusCode: __response.StatusCode) - { - ResponseBody = __content_401, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // - if ((int)__response.StatusCode == 403) - { - string? __content_403 = null; - global::System.Exception? __exception_403 = null; - try - { - if (ReadResponseAsString) - { - __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else + + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateEvent", + methodName: "CreateEventAsync", + pathTemplate: "$\"/api/tasks/{id}/events/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_403 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::LabelStudio.ApiException( - message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_403, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_403, - 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); + ProcessCreateEventResponse( + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateEvent", + methodName: "CreateEventAsync", + pathTemplate: "$\"/api/tasks/{id}/events/\"", + 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 { - __exception_404 = __ex; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateEvent", + methodName: "CreateEventAsync", + pathTemplate: "$\"/api/tasks/{id}/events/\"", + 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 ((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::LabelStudio.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), - }; - } + throw new global::LabelStudio.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 == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + throw new global::LabelStudio.ApiException( + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + statusCode: __response.StatusCode) + { + ResponseBody = __content_401, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessCreateEventResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + throw new global::LabelStudio.ApiException( + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + statusCode: __response.StatusCode) + { + ResponseBody = __content_403, + 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; + } - try - { - __response.EnsureSuccessStatusCode(); + throw new global::LabelStudio.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), + }; + } - return - global::LabelStudio.TaskEvent.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); - } - catch (global::System.Exception __ex) - { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - cancellationToken -#endif - ).ConfigureAwait(false); + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); - return - await global::LabelStudio.TaskEvent.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) - { - } + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessCreateEventResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.TaskEvent.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.TaskEvent.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 task event
@@ -439,6 +622,7 @@ partial void ProcessCreateEventResponseContent( /// /// Review ID associated with this event /// + /// 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 CreateEventAsync( @@ -449,6 +633,7 @@ partial void ProcessCreateEventResponseContent( int? annotationDraftId = default, object? meta = default, int? review = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.TaskEventRequest @@ -464,6 +649,7 @@ partial void ProcessCreateEventResponseContent( return await CreateEventAsync( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.Tasks2Client.CreateManyStatus.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Tasks2Client.CreateManyStatus.g.cs index a44574b..91d3764 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Tasks2Client.CreateManyStatus.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Tasks2Client.CreateManyStatus.g.cs @@ -14,6 +14,7 @@ public partial class Tasks2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -57,11 +58,13 @@ partial void ProcessCreateManyStatusResponseContent( ///
/// /// + /// 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 CreateManyStatusAsync( int id, int importPk, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -77,22 +80,43 @@ partial void ProcessCreateManyStatusResponseContent( securityRequirements: s_CreateManyStatusSecurityRequirements, operationName: "CreateManyStatusAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{id}/imports/{importPk}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{id}/imports/{importPk}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,113 +126,272 @@ partial void ProcessCreateManyStatusResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCreateManyStatusRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - importPk: importPk); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreateManyStatusRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + importPk: importPk); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreateManyStatusResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateManyStatus", + methodName: "CreateManyStatusAsync", + pathTemplate: "$\"/api/projects/{id}/imports/{importPk}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateManyStatus", + methodName: "CreateManyStatusAsync", + pathTemplate: "$\"/api/projects/{id}/imports/{importPk}/\"", + 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); - ProcessCreateManyStatusResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateManyStatus", + methodName: "CreateManyStatusAsync", + pathTemplate: "$\"/api/projects/{id}/imports/{importPk}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.ProjectImport.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.ProjectImport.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessCreateManyStatusResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateManyStatus", + methodName: "CreateManyStatusAsync", + pathTemplate: "$\"/api/projects/{id}/imports/{importPk}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateManyStatus", + methodName: "CreateManyStatusAsync", + pathTemplate: "$\"/api/projects/{id}/imports/{importPk}/\"", + 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); + ProcessCreateManyStatusResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.ProjectImport.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ProjectImport.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.Tasks2Client.Delete2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Tasks2Client.Delete2.g.cs index 57a01b9..6654aa0 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Tasks2Client.Delete2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Tasks2Client.Delete2.g.cs @@ -14,6 +14,7 @@ public partial class Tasks2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -40,10 +41,12 @@ partial void ProcessDelete2Response( /// Delete a task in Label Studio. This action cannot be undone! /// /// + /// 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 Delete2Async( string id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -58,22 +61,43 @@ partial void ProcessDelete2Response( securityRequirements: s_Delete2SecurityRequirements, operationName: "Delete2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/tasks/{id}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/tasks/{id}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -83,96 +107,255 @@ partial void ProcessDelete2Response( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDelete2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDelete2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/tasks/{id}/\"", + 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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/tasks/{id}/\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessDelete2Response( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/tasks/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessDelete2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/tasks/{id}/\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/tasks/{id}/\"", + httpMethod: "DELETE", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.Tasks2Client.DeleteAllTasks.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Tasks2Client.DeleteAllTasks.g.cs index 2b03b37..6862fe0 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Tasks2Client.DeleteAllTasks.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Tasks2Client.DeleteAllTasks.g.cs @@ -14,6 +14,7 @@ public partial class Tasks2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -40,10 +41,12 @@ partial void ProcessDeleteAllTasksResponse( /// Delete all tasks from a specific project. /// /// + /// 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 DeleteAllTasksAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -58,22 +61,43 @@ partial void ProcessDeleteAllTasksResponse( securityRequirements: s_DeleteAllTasksSecurityRequirements, operationName: "DeleteAllTasksAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{id}/tasks/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{id}/tasks/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -83,96 +107,255 @@ partial void ProcessDeleteAllTasksResponse( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDeleteAllTasksRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDeleteAllTasksRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteAllTasks", + methodName: "DeleteAllTasksAsync", + pathTemplate: "$\"/api/projects/{id}/tasks/\"", + 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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteAllTasks", + methodName: "DeleteAllTasksAsync", + pathTemplate: "$\"/api/projects/{id}/tasks/\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessDeleteAllTasksResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteAllTasks", + methodName: "DeleteAllTasksAsync", + pathTemplate: "$\"/api/projects/{id}/tasks/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessDeleteAllTasksResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteAllTasks", + methodName: "DeleteAllTasksAsync", + pathTemplate: "$\"/api/projects/{id}/tasks/\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteAllTasks", + methodName: "DeleteAllTasksAsync", + pathTemplate: "$\"/api/projects/{id}/tasks/\"", + httpMethod: "DELETE", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.Tasks2Client.Get.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Tasks2Client.Get.g.cs index a0d5268..b58b008 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Tasks2Client.Get.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Tasks2Client.Get.g.cs @@ -14,6 +14,7 @@ public partial class Tasks2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,10 +46,12 @@ partial void ProcessGetResponseContent( /// Get task data, metadata, annotations and other attributes for a specific labeling task by task ID. /// /// + /// 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 GetAsync( string id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -63,22 +66,43 @@ partial void ProcessGetResponseContent( securityRequirements: s_GetSecurityRequirements, operationName: "GetAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/tasks/{id}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/tasks/{id}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -88,112 +112,271 @@ partial void ProcessGetResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/tasks/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/tasks/{id}/\"", + 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); - ProcessGetResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/tasks/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.RoleBasedTask.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.RoleBasedTask.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGetResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/tasks/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/tasks/{id}/\"", + 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); + ProcessGetResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.RoleBasedTask.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.RoleBasedTask.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.Tasks2Client.List2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Tasks2Client.List2.g.cs index f44480c..c58d5de 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Tasks2Client.List2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Tasks2Client.List2.g.cs @@ -14,6 +14,7 @@ public partial class Tasks2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -78,6 +79,7 @@ partial void ProcessList2ResponseContent( /// /// /// + /// 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 List2Async( @@ -92,6 +94,7 @@ partial void ProcessList2ResponseContent( bool? review = default, string? selectedItems = default, int? view = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -116,35 +119,56 @@ partial void ProcessList2ResponseContent( securityRequirements: s_List2SecurityRequirements, operationName: "List2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/tasks/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("fields", fields?.ToValueString()) - .AddOptionalParameter("include", include) - .AddOptionalParameter("only_annotated", onlyAnnotated?.ToString().ToLowerInvariant()) - .AddOptionalParameter("page", page?.ToString()) - .AddOptionalParameter("page_size", pageSize?.ToString()) - .AddOptionalParameter("project", project?.ToString()) - .AddOptionalParameter("query", query) - .AddOptionalParameter("resolve_uri", resolveUri?.ToString().ToLowerInvariant()) - .AddOptionalParameter("review", review?.ToString().ToLowerInvariant()) - .AddOptionalParameter("selectedItems", selectedItems) - .AddOptionalParameter("view", view?.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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/tasks/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("fields", fields?.ToValueString()) + .AddOptionalParameter("include", include) + .AddOptionalParameter("only_annotated", onlyAnnotated?.ToString().ToLowerInvariant()) + .AddOptionalParameter("page", page?.ToString()) + .AddOptionalParameter("page_size", pageSize?.ToString()) + .AddOptionalParameter("project", project?.ToString()) + .AddOptionalParameter("query", query) + .AddOptionalParameter("resolve_uri", resolveUri?.ToString().ToLowerInvariant()) + .AddOptionalParameter("review", review?.ToString().ToLowerInvariant()) + .AddOptionalParameter("selectedItems", selectedItems) + .AddOptionalParameter("view", view?.ToString()) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -154,221 +178,380 @@ partial void ProcessList2ResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareList2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - fields: fields, - include: include, - onlyAnnotated: onlyAnnotated, - page: page, - pageSize: pageSize, - project: project, - query: query, - resolveUri: resolveUri, - review: review, - selectedItems: selectedItems, - view: view); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareList2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + fields: fields, + include: include, + onlyAnnotated: onlyAnnotated, + page: page, + pageSize: pageSize, + project: project, + query: query, + resolveUri: resolveUri, + review: review, + selectedItems: selectedItems, + view: view); - 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); - ProcessList2Response( - httpClient: HttpClient, - httpResponseMessage: __response); - // - if ((int)__response.StatusCode == 400) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_400 = null; - global::System.Exception? __exception_400 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/tasks/\"", + 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_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + __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_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - } - } - catch (global::System.Exception __ex) - { - __exception_400 = __ex; - } + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/tasks/\"", + 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; + } - throw new global::LabelStudio.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 == 401) - { - string? __content_401 = null; - global::System.Exception? __exception_401 = null; - try - { - if (ReadResponseAsString) - { - __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else + + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/tasks/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_401 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::LabelStudio.ApiException( - message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_401, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_401, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // - if ((int)__response.StatusCode == 403) - { - string? __content_403 = null; - global::System.Exception? __exception_403 = null; - try + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessList2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - if (ReadResponseAsString) - { - __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - } - else - { - __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/tasks/\"", + 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_403 = __ex; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/tasks/\"", + 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 ((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::LabelStudio.ApiException( - message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_403, - statusCode: __response.StatusCode) - { - ResponseBody = __content_403, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } + throw new global::LabelStudio.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 == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + throw new global::LabelStudio.ApiException( + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + statusCode: __response.StatusCode) + { + ResponseBody = __content_401, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessList2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + throw new global::LabelStudio.ApiException( + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + statusCode: __response.StatusCode) + { + ResponseBody = __content_403, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); - return - global::LabelStudio.PaginatedRoleBasedTaskList.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); - } - catch (global::System.Exception __ex) - { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - cancellationToken -#endif - ).ConfigureAwait(false); + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessList2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); - return - await global::LabelStudio.PaginatedRoleBasedTaskList.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) - { - } + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.PaginatedRoleBasedTaskList.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.PaginatedRoleBasedTaskList.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.Tasks2Client.Update2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Tasks2Client.Update2.g.cs index 63e71c4..cb5ec1e 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Tasks2Client.Update2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Tasks2Client.Update2.g.cs @@ -14,6 +14,7 @@ public partial class Tasks2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -48,12 +49,14 @@ partial void ProcessUpdate2ResponseContent( /// /// /// + /// 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 Update2Async( string id, global::LabelStudio.PatchedLseTaskRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -71,22 +74,43 @@ partial void ProcessUpdate2ResponseContent( securityRequirements: s_Update2SecurityRequirements, operationName: "Update2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/tasks/{id}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/tasks/{id}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -96,119 +120,278 @@ partial void ProcessUpdate2ResponseContent( __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); - PrepareUpdate2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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::LabelStudio.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); + PrepareUpdate2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessUpdate2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/tasks/{id}/\"", + 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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/tasks/{id}/\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessUpdate2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/tasks/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.RoleBasedTask.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.RoleBasedTask.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessUpdate2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/tasks/{id}/\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update2", + methodName: "Update2Async", + pathTemplate: "$\"/api/tasks/{id}/\"", + httpMethod: "PATCH", + 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); + ProcessUpdate2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.RoleBasedTask.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.RoleBasedTask.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 task
@@ -257,6 +440,7 @@ partial void ProcessUpdate2ResponseContent( /// /// Number of unresolved comments in the task including all annotations /// + /// 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 Update2Async( @@ -283,6 +467,7 @@ partial void ProcessUpdate2ResponseContent( int? totalAnnotations = default, int? totalPredictions = default, int? unresolvedCommentCount = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.PatchedLseTaskRequest @@ -314,6 +499,7 @@ partial void ProcessUpdate2ResponseContent( return await Update2Async( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.Tasks2Client.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Tasks2Client.g.cs index e5902e5..773cf09 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Tasks2Client.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Tasks2Client.g.cs @@ -30,6 +30,9 @@ public sealed partial class Tasks2Client : global::LabelStudio.ITasks2Client, gl #if DEBUG = true; #endif + + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public Tasks2Client( 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 Tasks2Client. + /// 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 Tasks2Client( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::LabelStudio.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::LabelStudio.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/LabelStudio/Generated/LabelStudio.TasksClient.ApiTasksAgreementRetrieve.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.TasksClient.ApiTasksAgreementRetrieve.g.cs index 1d8524b..4546541 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.TasksClient.ApiTasksAgreementRetrieve.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.TasksClient.ApiTasksAgreementRetrieve.g.cs @@ -14,6 +14,7 @@ public partial class TasksClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -40,10 +41,12 @@ partial void ProcessApiTasksAgreementRetrieveResponse( /// Get aggregated label distribution across all annotations for a task. Returns counts of each label value grouped by control tag. This is an efficient endpoint that avoids N+1 queries. ///
/// + /// 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 ApiTasksAgreementRetrieveAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -58,22 +61,43 @@ partial void ProcessApiTasksAgreementRetrieveResponse( securityRequirements: s_ApiTasksAgreementRetrieveSecurityRequirements, operationName: "ApiTasksAgreementRetrieveAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/tasks/{id}/agreement/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/tasks/{id}/agreement/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,96 +107,255 @@ partial void ProcessApiTasksAgreementRetrieveResponse( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareApiTasksAgreementRetrieveRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareApiTasksAgreementRetrieveRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiTasksAgreementRetrieve", + methodName: "ApiTasksAgreementRetrieveAsync", + pathTemplate: "$\"/api/tasks/{id}/agreement/\"", + 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: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiTasksAgreementRetrieve", + methodName: "ApiTasksAgreementRetrieveAsync", + pathTemplate: "$\"/api/tasks/{id}/agreement/\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiTasksAgreementRetrieveResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiTasksAgreementRetrieve", + methodName: "ApiTasksAgreementRetrieveAsync", + pathTemplate: "$\"/api/tasks/{id}/agreement/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessApiTasksAgreementRetrieveResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiTasksAgreementRetrieve", + methodName: "ApiTasksAgreementRetrieveAsync", + pathTemplate: "$\"/api/tasks/{id}/agreement/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiTasksAgreementRetrieve", + methodName: "ApiTasksAgreementRetrieveAsync", + pathTemplate: "$\"/api/tasks/{id}/agreement/\"", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.TasksClient.Assign.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.TasksClient.Assign.g.cs index 944d80a..b85b326 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.TasksClient.Assign.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.TasksClient.Assign.g.cs @@ -14,6 +14,7 @@ public partial class TasksClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -57,6 +58,7 @@ partial void ProcessAssignResponseContent( /// /// /// + /// 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 AssignAsync( @@ -64,6 +66,7 @@ partial void ProcessAssignResponseContent( int taskPk, global::LabelStudio.ApiProjectsTasksAssigneesCreate2Request request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -82,22 +85,43 @@ partial void ProcessAssignResponseContent( securityRequirements: s_AssignSecurityRequirements, operationName: "AssignAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{id}/tasks/{taskPk}/assignees", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{id}/tasks/{taskPk}/assignees", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -107,120 +131,279 @@ partial void ProcessAssignResponseContent( __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); - PrepareAssignRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - taskPk: taskPk, - 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::LabelStudio.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); + PrepareAssignRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + taskPk: taskPk, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessAssignResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Assign", + methodName: "AssignAsync", + pathTemplate: "$\"/api/projects/{id}/tasks/{taskPk}/assignees\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Assign", + methodName: "AssignAsync", + pathTemplate: "$\"/api/projects/{id}/tasks/{taskPk}/assignees\"", + 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); - ProcessAssignResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Assign", + methodName: "AssignAsync", + pathTemplate: "$\"/api/projects/{id}/tasks/{taskPk}/assignees\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.TaskAssignment.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.TaskAssignment.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessAssignResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Assign", + methodName: "AssignAsync", + pathTemplate: "$\"/api/projects/{id}/tasks/{taskPk}/assignees\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Assign", + methodName: "AssignAsync", + pathTemplate: "$\"/api/projects/{id}/tasks/{taskPk}/assignees\"", + 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); + ProcessAssignResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.TaskAssignment.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.TaskAssignment.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 task assignee
@@ -240,6 +423,7 @@ partial void ProcessAssignResponseContent( /// /// List of user IDs to assign /// + /// 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 AssignAsync( @@ -247,6 +431,7 @@ partial void ProcessAssignResponseContent( int taskPk, global::LabelStudio.ApiProjectsTasksAssigneesCreate2RequestType type, global::System.Collections.Generic.IList users, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.ApiProjectsTasksAssigneesCreate2Request @@ -259,6 +444,7 @@ partial void ProcessAssignResponseContent( id: id, taskPk: taskPk, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.TasksClient.BulkAssign.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.TasksClient.BulkAssign.g.cs index 9359cc9..60f6c29 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.TasksClient.BulkAssign.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.TasksClient.BulkAssign.g.cs @@ -14,6 +14,7 @@ public partial class TasksClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -54,12 +55,14 @@ partial void ProcessBulkAssignResponseContent( ///
/// /// + /// 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 BulkAssignAsync( int id, global::LabelStudio.ApiProjectsTasksAssigneesCreateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -77,22 +80,43 @@ partial void ProcessBulkAssignResponseContent( securityRequirements: s_BulkAssignSecurityRequirements, operationName: "BulkAssignAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{id}/tasks/assignees", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{id}/tasks/assignees", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -102,152 +126,311 @@ partial void ProcessBulkAssignResponseContent( __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::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareBulkAssignRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - request: request); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareBulkAssignRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + 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); - ProcessBulkAssignResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // - if ((int)__response.StatusCode == 400) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_400 = null; - global::System.Exception? __exception_400 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "BulkAssign", + methodName: "BulkAssignAsync", + pathTemplate: "$\"/api/projects/{id}/tasks/assignees\"", + 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) { - __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "BulkAssign", + methodName: "BulkAssignAsync", + pathTemplate: "$\"/api/projects/{id}/tasks/assignees\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else + + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "BulkAssign", + methodName: "BulkAssignAsync", + pathTemplate: "$\"/api/projects/{id}/tasks/assignees\"", + 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::LabelStudio.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::LabelStudio.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 (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); - ProcessBulkAssignResponseContent( + response: __response); + ProcessBulkAssignResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::LabelStudio.ApiProjectsTasksAssigneesCreateResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "BulkAssign", + methodName: "BulkAssignAsync", + pathTemplate: "$\"/api/projects/{id}/tasks/assignees\"", + 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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "BulkAssign", + methodName: "BulkAssignAsync", + pathTemplate: "$\"/api/projects/{id}/tasks/assignees\"", + 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); + // + 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; + } - return - await global::LabelStudio.ApiProjectsTasksAssigneesCreateResponse.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) - { - } + throw new global::LabelStudio.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 (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessBulkAssignResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.ApiProjectsTasksAssigneesCreateResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiProjectsTasksAssigneesCreateResponse.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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(); + } } /// /// ✨ Bulk assign users to tasks
@@ -272,6 +455,7 @@ partial void ProcessBulkAssignResponseContent( /// /// List of user IDs to assign /// + /// 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 BulkAssignAsync( @@ -280,6 +464,7 @@ partial void ProcessBulkAssignResponseContent( global::LabelStudio.ApiProjectsTasksAssigneesCreateRequestType type, global::System.Collections.Generic.IList users, global::LabelStudio.ApiProjectsTasksAssigneesCreateRequestFilters? filters = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.ApiProjectsTasksAssigneesCreateRequest @@ -293,6 +478,7 @@ partial void ProcessBulkAssignResponseContent( return await BulkAssignAsync( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.TasksClient.Delete.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.TasksClient.Delete.g.cs index f1cfcfe..054ea29 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.TasksClient.Delete.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.TasksClient.Delete.g.cs @@ -14,6 +14,7 @@ public partial class TasksClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -55,6 +56,7 @@ partial void ProcessDeleteResponse( /// /// /// + /// 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 DeleteAsync( @@ -62,6 +64,7 @@ partial void ProcessDeleteResponse( int taskPk, global::LabelStudio.ApiProjectsTasksAssigneesDestroyType? type = default, string? users = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -79,26 +82,47 @@ partial void ProcessDeleteResponse( securityRequirements: s_DeleteSecurityRequirements, operationName: "DeleteAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{id}/tasks/{taskPk}/assignees", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("type", type?.ToValueString()) - .AddOptionalParameter("users", users) - ; - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{id}/tasks/{taskPk}/assignees", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("type", type?.ToValueString()) + .AddOptionalParameter("users", users) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -108,99 +132,258 @@ partial void ProcessDeleteResponse( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDeleteRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - taskPk: taskPk, - type: type, - users: users); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDeleteRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + taskPk: taskPk, + type: type, + users: users); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/projects/{id}/tasks/{taskPk}/assignees\"", + 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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/projects/{id}/tasks/{taskPk}/assignees\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessDeleteResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/projects/{id}/tasks/{taskPk}/assignees\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessDeleteResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/projects/{id}/tasks/{taskPk}/assignees\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/projects/{id}/tasks/{taskPk}/assignees\"", + httpMethod: "DELETE", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.TasksClient.List.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.TasksClient.List.g.cs index 6ed8b3c..4a8a801 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.TasksClient.List.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.TasksClient.List.g.cs @@ -14,6 +14,7 @@ public partial class TasksClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -54,11 +55,13 @@ partial void ProcessListResponseContent( ///
/// /// + /// 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> ListAsync( int id, int taskPk, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -74,22 +77,43 @@ partial void ProcessListResponseContent( securityRequirements: s_ListSecurityRequirements, operationName: "ListAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{id}/tasks/{taskPk}/assignees", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{id}/tasks/{taskPk}/assignees", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -99,113 +123,272 @@ partial void ProcessListResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareListRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - taskPk: taskPk); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareListRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + taskPk: taskPk); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessListResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "$\"/api/projects/{id}/tasks/{taskPk}/assignees\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "$\"/api/projects/{id}/tasks/{taskPk}/assignees\"", + 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); - ProcessListResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "$\"/api/projects/{id}/tasks/{taskPk}/assignees\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessListResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "$\"/api/projects/{id}/tasks/{taskPk}/assignees\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "$\"/api/projects/{id}/tasks/{taskPk}/assignees\"", + 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); + ProcessListResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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 + (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.TasksClient.Update.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.TasksClient.Update.g.cs index 30e943b..9dce2a8 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.TasksClient.Update.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.TasksClient.Update.g.cs @@ -14,6 +14,7 @@ public partial class TasksClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -57,6 +58,7 @@ partial void ProcessUpdateResponseContent( /// /// /// + /// 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 UpdateAsync( @@ -64,6 +66,7 @@ partial void ProcessUpdateResponseContent( int taskPk, global::LabelStudio.ApiProjectsTasksAssigneesPartialUpdateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -82,22 +85,43 @@ partial void ProcessUpdateResponseContent( securityRequirements: s_UpdateSecurityRequirements, operationName: "UpdateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/projects/{id}/tasks/{taskPk}/assignees", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/projects/{id}/tasks/{taskPk}/assignees", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -107,120 +131,279 @@ partial void ProcessUpdateResponseContent( __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); - PrepareUpdateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - taskPk: taskPk, - 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::LabelStudio.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); + PrepareUpdateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + taskPk: taskPk, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessUpdateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/projects/{id}/tasks/{taskPk}/assignees\"", + 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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/projects/{id}/tasks/{taskPk}/assignees\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessUpdateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/projects/{id}/tasks/{taskPk}/assignees\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.TaskAssignment.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.TaskAssignment.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessUpdateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/projects/{id}/tasks/{taskPk}/assignees\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/projects/{id}/tasks/{taskPk}/assignees\"", + httpMethod: "PATCH", + 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); + ProcessUpdateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.TaskAssignment.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.TaskAssignment.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 task assignee
@@ -240,6 +423,7 @@ partial void ProcessUpdateResponseContent( /// /// List of user IDs to assign /// + /// 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 UpdateAsync( @@ -247,6 +431,7 @@ partial void ProcessUpdateResponseContent( int taskPk, global::LabelStudio.ApiProjectsTasksAssigneesPartialUpdateRequestType type, global::System.Collections.Generic.IList users, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.ApiProjectsTasksAssigneesPartialUpdateRequest @@ -259,6 +444,7 @@ partial void ProcessUpdateResponseContent( id: id, taskPk: taskPk, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.TasksClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.TasksClient.g.cs index 47c5189..44f22ec 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.TasksClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.TasksClient.g.cs @@ -30,6 +30,9 @@ public sealed partial class TasksClient : global::LabelStudio.ITasksClient, glob #if DEBUG = true; #endif + + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public TasksClient( 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 TasksClient. + /// 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 TasksClient( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::LabelStudio.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::LabelStudio.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/LabelStudio/Generated/LabelStudio.TokensClient.Blacklist.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.TokensClient.Blacklist.g.cs index f2d6744..2799efd 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.TokensClient.Blacklist.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.TokensClient.Blacklist.g.cs @@ -14,6 +14,7 @@ public partial class TokensClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,11 +46,13 @@ partial void ProcessBlacklistResponseContent( /// Adds a JWT refresh token to the blacklist, preventing it from being used to obtain new access tokens. ///
/// + /// 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 BlacklistAsync( global::LabelStudio.LSAPITokenBlacklistRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -66,22 +69,43 @@ partial void ProcessBlacklistResponseContent( securityRequirements: s_BlacklistSecurityRequirements, operationName: "BlacklistAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/token/blacklist/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/token/blacklist/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,152 +115,311 @@ partial void ProcessBlacklistResponseContent( __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); - PrepareBlacklistRequest( - 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::LabelStudio.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); + PrepareBlacklistRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessBlacklistResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // - if ((int)__response.StatusCode == 404) + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_404 = null; - global::System.Exception? __exception_404 = null; - string? __value_404 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Blacklist", + methodName: "BlacklistAsync", + pathTemplate: "\"/api/token/blacklist/\"", + 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_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_404 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, 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_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Blacklist", + methodName: "BlacklistAsync", + pathTemplate: "\"/api/token/blacklist/\"", + 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_404 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(string), JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Blacklist", + methodName: "BlacklistAsync", + pathTemplate: "\"/api/token/blacklist/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_404 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::LabelStudio.ApiException( - message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_404, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_404, - ResponseObject = __value_404, - 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); - ProcessBlacklistResponseContent( + response: __response); + ProcessBlacklistResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return __content; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Blacklist", + methodName: "BlacklistAsync", + pathTemplate: "\"/api/token/blacklist/\"", + 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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Blacklist", + methodName: "BlacklistAsync", + pathTemplate: "\"/api/token/blacklist/\"", + 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); + // + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + string? __value_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_404 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(string), JsonSerializerContext); + } + else + { + __content_404 = 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_404 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(string), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } + + throw new global::LabelStudio.ApiException( + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + statusCode: __response.StatusCode) + { + ResponseBody = __content_404, + ResponseObject = __value_404, + 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); + ProcessBlacklistResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return __content; + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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(); + } } /// /// Blacklist a JWT refresh token
@@ -245,10 +428,12 @@ partial void ProcessBlacklistResponseContent( /// /// Included only in requests /// + /// 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 BlacklistAsync( string refresh, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.LSAPITokenBlacklistRequest @@ -258,6 +443,7 @@ partial void ProcessBlacklistResponseContent( return await BlacklistAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.TokensClient.Create.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.TokensClient.Create.g.cs index 12ae41b..36cf19a 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.TokensClient.Create.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.TokensClient.Create.g.cs @@ -14,6 +14,7 @@ public partial class TokensClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -42,9 +43,11 @@ partial void ProcessCreateResponseContent( /// Create API token
/// Create a new API token for the current user. ///
+ /// 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 CreateAsync( + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -58,22 +61,43 @@ partial void ProcessCreateResponseContent( securityRequirements: s_CreateSecurityRequirements, operationName: "CreateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/token/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/token/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -83,111 +107,270 @@ partial void ProcessCreateResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCreateRequest( - 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); + PrepareCreateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/token/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/token/\"", + 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); - ProcessCreateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/token/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.LSEAPITokenCreate.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.LSEAPITokenCreate.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessCreateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/token/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/token/\"", + 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); + ProcessCreateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.LSEAPITokenCreate.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.LSEAPITokenCreate.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.TokensClient.List.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.TokensClient.List.g.cs index 76c59ad..1f94144 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.TokensClient.List.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.TokensClient.List.g.cs @@ -14,6 +14,7 @@ public partial class TokensClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,10 +46,12 @@ partial void ProcessListResponseContent( /// List all API tokens for the current user. /// /// + /// 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> ListAsync( string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -63,25 +66,46 @@ partial void ProcessListResponseContent( securityRequirements: s_ListSecurityRequirements, operationName: "ListAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/token/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("ordering", ordering) - ; - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/token/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("ordering", ordering) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -91,112 +115,271 @@ partial void ProcessListResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareListRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - ordering: ordering); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareListRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + ordering: ordering); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessListResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/token/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/token/\"", + 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); - ProcessListResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/token/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessListResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/token/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/token/\"", + 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); + ProcessListResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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 + (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.TokensClient.Refresh.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.TokensClient.Refresh.g.cs index 08d626c..aa8858c 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.TokensClient.Refresh.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.TokensClient.Refresh.g.cs @@ -14,6 +14,7 @@ public partial class TokensClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,11 +46,13 @@ partial void ProcessRefreshResponseContent( /// Get a new access token, using a refresh token. /// /// + /// 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 RefreshAsync( global::LabelStudio.TokenRefreshRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -66,22 +69,43 @@ partial void ProcessRefreshResponseContent( securityRequirements: s_RefreshSecurityRequirements, operationName: "RefreshAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/token/refresh/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/token/refresh/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,118 +115,277 @@ partial void ProcessRefreshResponseContent( __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); - PrepareRefreshRequest( - 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::LabelStudio.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); + PrepareRefreshRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessRefreshResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Refresh", + methodName: "RefreshAsync", + pathTemplate: "\"/api/token/refresh/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Refresh", + methodName: "RefreshAsync", + pathTemplate: "\"/api/token/refresh/\"", + 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); - ProcessRefreshResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Refresh", + methodName: "RefreshAsync", + pathTemplate: "\"/api/token/refresh/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.TokenRefreshResponse.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.TokenRefreshResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessRefreshResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Refresh", + methodName: "RefreshAsync", + pathTemplate: "\"/api/token/refresh/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Refresh", + methodName: "RefreshAsync", + pathTemplate: "\"/api/token/refresh/\"", + 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); + ProcessRefreshResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.TokenRefreshResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.TokenRefreshResponse.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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(); + } } /// /// Refresh JWT token
@@ -211,10 +394,12 @@ partial void ProcessRefreshResponseContent( /// /// Included only in requests /// + /// 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 RefreshAsync( string refresh, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.TokenRefreshRequest @@ -224,6 +409,7 @@ partial void ProcessRefreshResponseContent( return await RefreshAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.TokensClient.Rotate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.TokensClient.Rotate.g.cs index f66a22e..d4bb1db 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.TokensClient.Rotate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.TokensClient.Rotate.g.cs @@ -14,6 +14,7 @@ public partial class TokensClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,11 +46,13 @@ partial void ProcessRotateResponseContent( /// Creates a new JWT refresh token and blacklists the current one. ///
/// + /// 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 RotateAsync( global::LabelStudio.LSAPITokenRotateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -66,22 +69,43 @@ partial void ProcessRotateResponseContent( securityRequirements: s_RotateSecurityRequirements, operationName: "RotateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/token/rotate/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/token/rotate/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,166 +115,327 @@ partial void ProcessRotateResponseContent( __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); - PrepareRotateRequest( - 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::LabelStudio.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); + PrepareRotateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessRotateResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // - if ((int)__response.StatusCode == 400) + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_400 = null; - global::System.Exception? __exception_400 = null; - string? __value_400 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Rotate", + methodName: "RotateAsync", + pathTemplate: "\"/api/token/rotate/\"", + 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_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, 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_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Rotate", + methodName: "RotateAsync", + pathTemplate: "\"/api/token/rotate/\"", + 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_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Rotate", + methodName: "RotateAsync", + pathTemplate: "\"/api/token/rotate/\"", + 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::LabelStudio.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::LabelStudio.ApiException( - message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_400, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_400, - ResponseObject = __value_400, - 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); - ProcessRotateResponseContent( + response: __response); + ProcessRotateResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::LabelStudio.TokenRotateResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Rotate", + methodName: "RotateAsync", + pathTemplate: "\"/api/token/rotate/\"", + 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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Rotate", + methodName: "RotateAsync", + pathTemplate: "\"/api/token/rotate/\"", + 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); + // + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + string? __value_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::LabelStudio.TokenRotateResponse.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_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::LabelStudio.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseObject = __value_400, + 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); + ProcessRotateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.TokenRotateResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.TokenRotateResponse.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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(); + } } /// /// Rotate JWT refresh token
/// Creates a new JWT refresh token and blacklists the current one. ///
/// + /// 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 RotateAsync( string refresh, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.LSAPITokenRotateRequest @@ -260,6 +445,7 @@ partial void ProcessRotateResponseContent( return await RotateAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.TokensClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.TokensClient.g.cs index 494d3dc..2abce8c 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.TokensClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.TokensClient.g.cs @@ -30,6 +30,9 @@ public sealed partial class TokensClient : global::LabelStudio.ITokensClient, gl #if DEBUG = true; #endif + + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public TokensClient( 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 TokensClient. + /// 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 TokensClient( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::LabelStudio.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::LabelStudio.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/LabelStudio/Generated/LabelStudio.UsersClient.Create.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.UsersClient.Create.g.cs index d938d8f..a493906 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.UsersClient.Create.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.UsersClient.Create.g.cs @@ -14,6 +14,7 @@ public partial class UsersClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,11 +46,13 @@ partial void ProcessCreateResponseContent( /// Create a user in Label Studio. /// /// + /// 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 CreateAsync( global::LabelStudio.ApiUsersCreateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -66,22 +69,43 @@ partial void ProcessCreateResponseContent( securityRequirements: s_CreateSecurityRequirements, operationName: "CreateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/users/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/users/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,118 +115,277 @@ partial void ProcessCreateResponseContent( __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::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCreateRequest( - 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); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/users/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/users/\"", + 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); - ProcessCreateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/users/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.LseUser.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.LseUser.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessCreateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/users/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/users/\"", + 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); + ProcessCreateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.LseUser.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.LseUser.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 new user
@@ -235,6 +418,7 @@ partial void ProcessCreateResponseContent( /// /// Username of the user /// + /// 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 CreateAsync( @@ -247,6 +431,7 @@ partial void ProcessCreateResponseContent( string? lastName = default, string? phone = default, string? username = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.ApiUsersCreateRequest @@ -264,6 +449,7 @@ partial void ProcessCreateResponseContent( return await CreateAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.UsersClient.Delete.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.UsersClient.Delete.g.cs index dda71b1..e131b44 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.UsersClient.Delete.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.UsersClient.Delete.g.cs @@ -14,6 +14,7 @@ public partial class UsersClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -41,10 +42,12 @@ partial void ProcessDeleteResponse( /// <Warning>Use caution when deleting a user, as this can cause issues such as breaking the "Annotated by" filter or leaving orphaned records.</Warning> ///
/// + /// 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 DeleteAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -59,22 +62,43 @@ partial void ProcessDeleteResponse( securityRequirements: s_DeleteSecurityRequirements, operationName: "DeleteAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/users/{id}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/users/{id}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -84,96 +108,255 @@ partial void ProcessDeleteResponse( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDeleteRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDeleteRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/users/{id}/\"", + 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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/users/{id}/\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessDeleteResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/users/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessDeleteResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/users/{id}/\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/users/{id}/\"", + httpMethod: "DELETE", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.UsersClient.Get.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.UsersClient.Get.g.cs index 7e41106..c0d6eb6 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.UsersClient.Get.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.UsersClient.Get.g.cs @@ -14,6 +14,7 @@ public partial class UsersClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,10 +46,12 @@ partial void ProcessGetResponseContent( /// Get info about a specific Label Studio user, based on the user ID. /// /// + /// 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 GetAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -63,22 +66,43 @@ partial void ProcessGetResponseContent( securityRequirements: s_GetSecurityRequirements, operationName: "GetAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/users/{id}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/users/{id}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -88,112 +112,271 @@ partial void ProcessGetResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/users/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/users/{id}/\"", + 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); - ProcessGetResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/users/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.LseUser.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.LseUser.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGetResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/users/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/users/{id}/\"", + 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); + ProcessGetResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.LseUser.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.LseUser.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.UsersClient.GetCurrentUser.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.UsersClient.GetCurrentUser.g.cs index 8bdf8c9..656876c 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.UsersClient.GetCurrentUser.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.UsersClient.GetCurrentUser.g.cs @@ -14,6 +14,7 @@ public partial class UsersClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -48,9 +49,11 @@ partial void ProcessGetCurrentUserResponseContent( /// </Card>
/// Get info about the currently authenticated user. /// + /// 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 GetCurrentUserAsync( + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -64,22 +67,43 @@ partial void ProcessGetCurrentUserResponseContent( securityRequirements: s_GetCurrentUserSecurityRequirements, operationName: "GetCurrentUserAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/current-user", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/current-user", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,111 +113,270 @@ partial void ProcessGetCurrentUserResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetCurrentUserRequest( - 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); + PrepareGetCurrentUserRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetCurrentUserResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetCurrentUser", + methodName: "GetCurrentUserAsync", + pathTemplate: "\"/api/current-user\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetCurrentUser", + methodName: "GetCurrentUserAsync", + pathTemplate: "\"/api/current-user\"", + 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); - ProcessGetCurrentUserResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetCurrentUser", + methodName: "GetCurrentUserAsync", + pathTemplate: "\"/api/current-user\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.LseUserAPI.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.LseUserAPI.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGetCurrentUserResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetCurrentUser", + methodName: "GetCurrentUserAsync", + pathTemplate: "\"/api/current-user\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetCurrentUser", + methodName: "GetCurrentUserAsync", + pathTemplate: "\"/api/current-user\"", + 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); + ProcessGetCurrentUserResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.LseUserAPI.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.LseUserAPI.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.UsersClient.GetHotkeys.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.UsersClient.GetHotkeys.g.cs index 54e3189..3fa7f81 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.UsersClient.GetHotkeys.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.UsersClient.GetHotkeys.g.cs @@ -14,6 +14,7 @@ public partial class UsersClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -42,9 +43,11 @@ partial void ProcessGetHotkeysResponseContent( /// Get user hotkeys
/// Retrieve the custom hotkeys configuration for the current user. /// + /// 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 GetHotkeysAsync( + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -58,22 +61,43 @@ partial void ProcessGetHotkeysResponseContent( securityRequirements: s_GetHotkeysSecurityRequirements, operationName: "GetHotkeysAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/current-user/hotkeys/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/current-user/hotkeys/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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 ProcessGetHotkeysResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetHotkeysRequest( - 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); + PrepareGetHotkeysRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetHotkeysResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetHotkeys", + methodName: "GetHotkeysAsync", + pathTemplate: "\"/api/current-user/hotkeys/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetHotkeys", + methodName: "GetHotkeysAsync", + pathTemplate: "\"/api/current-user/hotkeys/\"", + 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); - ProcessGetHotkeysResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetHotkeys", + methodName: "GetHotkeysAsync", + pathTemplate: "\"/api/current-user/hotkeys/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.Hotkeys.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.Hotkeys.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGetHotkeysResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetHotkeys", + methodName: "GetHotkeysAsync", + pathTemplate: "\"/api/current-user/hotkeys/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetHotkeys", + methodName: "GetHotkeysAsync", + pathTemplate: "\"/api/current-user/hotkeys/\"", + 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); + ProcessGetHotkeysResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.Hotkeys.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.Hotkeys.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.UsersClient.GetToken.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.UsersClient.GetToken.g.cs index 5665060..1589ef1 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.UsersClient.GetToken.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.UsersClient.GetToken.g.cs @@ -14,6 +14,7 @@ public partial class UsersClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -42,9 +43,11 @@ partial void ProcessGetTokenResponseContent( /// Get user token
/// Get a user token to authenticate to the API as the current user. /// + /// 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 GetTokenAsync( + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -58,22 +61,43 @@ partial void ProcessGetTokenResponseContent( securityRequirements: s_GetTokenSecurityRequirements, operationName: "GetTokenAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/current-user/token", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/current-user/token", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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 ProcessGetTokenResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetTokenRequest( - 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); + PrepareGetTokenRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetTokenResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetToken", + methodName: "GetTokenAsync", + pathTemplate: "\"/api/current-user/token\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetToken", + methodName: "GetTokenAsync", + pathTemplate: "\"/api/current-user/token\"", + 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); - ProcessGetTokenResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetToken", + methodName: "GetTokenAsync", + pathTemplate: "\"/api/current-user/token\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.ApiCurrentUserTokenRetrieveResponse.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.ApiCurrentUserTokenRetrieveResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGetTokenResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetToken", + methodName: "GetTokenAsync", + pathTemplate: "\"/api/current-user/token\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetToken", + methodName: "GetTokenAsync", + pathTemplate: "\"/api/current-user/token\"", + 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); + ProcessGetTokenResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.ApiCurrentUserTokenRetrieveResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiCurrentUserTokenRetrieveResponse.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.UsersClient.List.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.UsersClient.List.g.cs index 3aac987..3a6511d 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.UsersClient.List.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.UsersClient.List.g.cs @@ -14,6 +14,7 @@ public partial class UsersClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,10 +46,12 @@ partial void ProcessListResponseContent( /// List the users that exist on the Label Studio server. /// /// + /// 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> ListAsync( string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -63,25 +66,46 @@ partial void ProcessListResponseContent( securityRequirements: s_ListSecurityRequirements, operationName: "ListAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/users/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("ordering", ordering) - ; - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/users/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("ordering", ordering) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -91,112 +115,271 @@ partial void ProcessListResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareListRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - ordering: ordering); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareListRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + ordering: ordering); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessListResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/users/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/users/\"", + 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); - ProcessListResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/users/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessListResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/users/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/users/\"", + 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); + ProcessListResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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 + (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.UsersClient.ResetToken.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.UsersClient.ResetToken.g.cs index dce143d..73eab0a 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.UsersClient.ResetToken.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.UsersClient.ResetToken.g.cs @@ -14,6 +14,7 @@ public partial class UsersClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -42,9 +43,11 @@ partial void ProcessResetTokenResponseContent( /// Reset user token
/// Reset the user token for the current user. /// + /// 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 ResetTokenAsync( + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -58,22 +61,43 @@ partial void ProcessResetTokenResponseContent( securityRequirements: s_ResetTokenSecurityRequirements, operationName: "ResetTokenAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/current-user/reset-token/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/current-user/reset-token/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -83,111 +107,270 @@ partial void ProcessResetTokenResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareResetTokenRequest( - 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); + PrepareResetTokenRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessResetTokenResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ResetToken", + methodName: "ResetTokenAsync", + pathTemplate: "\"/api/current-user/reset-token/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ResetToken", + methodName: "ResetTokenAsync", + pathTemplate: "\"/api/current-user/reset-token/\"", + 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); - ProcessResetTokenResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ResetToken", + methodName: "ResetTokenAsync", + pathTemplate: "\"/api/current-user/reset-token/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.ApiCurrentUserResetTokenCreateResponse.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.ApiCurrentUserResetTokenCreateResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessResetTokenResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ResetToken", + methodName: "ResetTokenAsync", + pathTemplate: "\"/api/current-user/reset-token/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ResetToken", + methodName: "ResetTokenAsync", + pathTemplate: "\"/api/current-user/reset-token/\"", + 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); + ProcessResetTokenResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.ApiCurrentUserResetTokenCreateResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiCurrentUserResetTokenCreateResponse.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.UsersClient.Update.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.UsersClient.Update.g.cs index 171ff93..813381e 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.UsersClient.Update.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.UsersClient.Update.g.cs @@ -14,6 +14,7 @@ public partial class UsersClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -49,12 +50,14 @@ partial void ProcessUpdateResponseContent( /// /// /// + /// 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 UpdateAsync( int id, global::LabelStudio.ApiUsersPartialUpdateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -72,22 +75,43 @@ partial void ProcessUpdateResponseContent( securityRequirements: s_UpdateSecurityRequirements, operationName: "UpdateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/users/{id}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/users/{id}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -97,119 +121,278 @@ partial void ProcessUpdateResponseContent( __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); - PrepareUpdateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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::LabelStudio.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); + PrepareUpdateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessUpdateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/users/{id}/\"", + 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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/users/{id}/\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessUpdateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/users/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.LseUser.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.LseUser.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessUpdateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/users/{id}/\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/users/{id}/\"", + httpMethod: "PATCH", + 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); + ProcessUpdateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.LseUser.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.LseUser.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 user details
@@ -244,6 +427,7 @@ partial void ProcessUpdateResponseContent( /// /// Username of the user /// + /// 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 UpdateAsync( @@ -257,6 +441,7 @@ partial void ProcessUpdateResponseContent( string? lastName = default, string? phone = default, string? username = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.ApiUsersPartialUpdateRequest @@ -275,6 +460,7 @@ partial void ProcessUpdateResponseContent( return await UpdateAsync( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.UsersClient.UpdateCurrentUser.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.UsersClient.UpdateCurrentUser.g.cs index a511629..3c0a6fd 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.UsersClient.UpdateCurrentUser.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.UsersClient.UpdateCurrentUser.g.cs @@ -14,6 +14,7 @@ public partial class UsersClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,11 +52,13 @@ partial void ProcessUpdateCurrentUserResponseContent( /// Update details for the currently authenticated user. ///
/// + /// 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 UpdateCurrentUserAsync( global::LabelStudio.PatchedLseUserSerializerUpdateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -72,22 +75,43 @@ partial void ProcessUpdateCurrentUserResponseContent( securityRequirements: s_UpdateCurrentUserSecurityRequirements, operationName: "UpdateCurrentUserAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/current-user", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/current-user", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -97,118 +121,277 @@ partial void ProcessUpdateCurrentUserResponseContent( __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::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareUpdateCurrentUserRequest( - 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); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareUpdateCurrentUserRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessUpdateCurrentUserResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateCurrentUser", + methodName: "UpdateCurrentUserAsync", + pathTemplate: "\"/api/current-user\"", + 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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateCurrentUser", + methodName: "UpdateCurrentUserAsync", + pathTemplate: "\"/api/current-user\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessUpdateCurrentUserResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateCurrentUser", + methodName: "UpdateCurrentUserAsync", + pathTemplate: "\"/api/current-user\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.LseUserAPI.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.LseUserAPI.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessUpdateCurrentUserResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateCurrentUser", + methodName: "UpdateCurrentUserAsync", + pathTemplate: "\"/api/current-user\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateCurrentUser", + methodName: "UpdateCurrentUserAsync", + pathTemplate: "\"/api/current-user\"", + httpMethod: "PATCH", + 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); + ProcessUpdateCurrentUserResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.LseUserAPI.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.LseUserAPI.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 current user
@@ -244,6 +427,7 @@ partial void ProcessUpdateCurrentUserResponseContent( /// /// /// + /// 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 UpdateCurrentUserAsync( @@ -259,6 +443,7 @@ partial void ProcessUpdateCurrentUserResponseContent( string? lastName = default, string? phone = default, string? username = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.PatchedLseUserSerializerUpdateRequest @@ -279,6 +464,7 @@ partial void ProcessUpdateCurrentUserResponseContent( return await UpdateCurrentUserAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.UsersClient.UpdateHotkeys.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.UsersClient.UpdateHotkeys.g.cs index 0c714a6..86ba312 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.UsersClient.UpdateHotkeys.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.UsersClient.UpdateHotkeys.g.cs @@ -14,6 +14,7 @@ public partial class UsersClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,11 +46,13 @@ partial void ProcessUpdateHotkeysResponseContent( /// Update the custom hotkeys configuration for the current user. ///
/// + /// 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 UpdateHotkeysAsync( global::LabelStudio.PatchedHotkeysRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -66,22 +69,43 @@ partial void ProcessUpdateHotkeysResponseContent( securityRequirements: s_UpdateHotkeysSecurityRequirements, operationName: "UpdateHotkeysAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/current-user/hotkeys/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/current-user/hotkeys/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -91,128 +115,289 @@ partial void ProcessUpdateHotkeysResponseContent( __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); - PrepareUpdateHotkeysRequest( - 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::LabelStudio.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); + PrepareUpdateHotkeysRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessUpdateHotkeysResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateHotkeys", + methodName: "UpdateHotkeysAsync", + pathTemplate: "\"/api/current-user/hotkeys/\"", + 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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateHotkeys", + methodName: "UpdateHotkeysAsync", + pathTemplate: "\"/api/current-user/hotkeys/\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessUpdateHotkeysResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateHotkeys", + methodName: "UpdateHotkeysAsync", + pathTemplate: "\"/api/current-user/hotkeys/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.Hotkeys.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.Hotkeys.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessUpdateHotkeysResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateHotkeys", + methodName: "UpdateHotkeysAsync", + pathTemplate: "\"/api/current-user/hotkeys/\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateHotkeys", + methodName: "UpdateHotkeysAsync", + pathTemplate: "\"/api/current-user/hotkeys/\"", + httpMethod: "PATCH", + 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); + ProcessUpdateHotkeysResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.Hotkeys.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.Hotkeys.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 user hotkeys
/// Update the custom hotkeys configuration for the current user. ///
/// + /// 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 UpdateHotkeysAsync( object? customHotkeys = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.PatchedHotkeysRequest @@ -222,6 +407,7 @@ partial void ProcessUpdateHotkeysResponseContent( return await UpdateHotkeysAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.UsersClient.Whoami.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.UsersClient.Whoami.g.cs index a73af1b..6f551e5 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.UsersClient.Whoami.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.UsersClient.Whoami.g.cs @@ -14,6 +14,7 @@ public partial class UsersClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -42,9 +43,11 @@ partial void ProcessWhoamiResponseContent( /// Retrieve my user
/// Retrieve details of the account that you are using to access the API. /// + /// 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 WhoamiAsync( + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -58,22 +61,43 @@ partial void ProcessWhoamiResponseContent( securityRequirements: s_WhoamiSecurityRequirements, operationName: "WhoamiAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/current-user/whoami", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/current-user/whoami", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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 ProcessWhoamiResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareWhoamiRequest( - 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); + PrepareWhoamiRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessWhoamiResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Whoami", + methodName: "WhoamiAsync", + pathTemplate: "\"/api/current-user/whoami\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Whoami", + methodName: "WhoamiAsync", + pathTemplate: "\"/api/current-user/whoami\"", + 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); - ProcessWhoamiResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Whoami", + methodName: "WhoamiAsync", + pathTemplate: "\"/api/current-user/whoami\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.WhoAmIUser.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.WhoAmIUser.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessWhoamiResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Whoami", + methodName: "WhoamiAsync", + pathTemplate: "\"/api/current-user/whoami\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Whoami", + methodName: "WhoamiAsync", + pathTemplate: "\"/api/current-user/whoami\"", + 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); + ProcessWhoamiResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.WhoAmIUser.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.WhoAmIUser.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.UsersClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.UsersClient.g.cs index 6c6567a..a1b0ad0 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.UsersClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.UsersClient.g.cs @@ -30,6 +30,9 @@ public sealed partial class UsersClient : global::LabelStudio.IUsersClient, glob #if DEBUG = true; #endif + + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public UsersClient( 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 UsersClient. + /// 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 UsersClient( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::LabelStudio.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::LabelStudio.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/LabelStudio/Generated/LabelStudio.VersionsClient.Get.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.VersionsClient.Get.g.cs index 370e9eb..dd763c5 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.VersionsClient.Get.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.VersionsClient.Get.g.cs @@ -14,6 +14,7 @@ public partial class VersionsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,9 +52,11 @@ partial void ProcessGetResponseContent( /// Get version information
/// Get version information about the Label Studio instance. /// + /// 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 GetAsync( + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -67,22 +70,43 @@ partial void ProcessGetResponseContent( securityRequirements: s_GetSecurityRequirements, operationName: "GetAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/version/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/version/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -92,111 +116,270 @@ partial void ProcessGetResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetRequest( - 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); + PrepareGetRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "\"/api/version/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "\"/api/version/\"", + 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); - ProcessGetResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "\"/api/version/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.VersionResponse.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.VersionResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGetResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "\"/api/version/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "\"/api/version/\"", + 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); + ProcessGetResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.VersionResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.VersionResponse.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.VersionsClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.VersionsClient.g.cs index 27a0e71..eb8f0a6 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.VersionsClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.VersionsClient.g.cs @@ -30,6 +30,9 @@ public sealed partial class VersionsClient : global::LabelStudio.IVersionsClient #if DEBUG = true; #endif + + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public VersionsClient( 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 VersionsClient. + /// 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 VersionsClient( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::LabelStudio.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::LabelStudio.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ViewsClient.Create2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ViewsClient.Create2.g.cs index 13f88c1..598a2ff 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ViewsClient.Create2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ViewsClient.Create2.g.cs @@ -14,6 +14,7 @@ public partial class ViewsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,11 +46,13 @@ partial void ProcessCreate2ResponseContent( /// Create a view for a specific project. /// /// + /// 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 Create2Async( global::LabelStudio.ApiDmViewsCreateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -66,22 +69,43 @@ partial void ProcessCreate2ResponseContent( securityRequirements: s_Create2SecurityRequirements, operationName: "Create2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/dm/views/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/dm/views/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,118 +115,277 @@ partial void ProcessCreate2ResponseContent( __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); - PrepareCreate2Request( - 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::LabelStudio.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); + PrepareCreate2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreate2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "\"/api/dm/views/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "\"/api/dm/views/\"", + 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); - ProcessCreate2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "\"/api/dm/views/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.View.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.View.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessCreate2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "\"/api/dm/views/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "\"/api/dm/views/\"", + 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); + ProcessCreate2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.View.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.View.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 view
@@ -214,11 +397,13 @@ partial void ProcessCreate2ResponseContent( /// /// Project ID /// + /// 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 Create2Async( global::LabelStudio.ApiDmViewsCreateRequestData? data = default, int? project = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.ApiDmViewsCreateRequest @@ -229,6 +414,7 @@ partial void ProcessCreate2ResponseContent( return await Create2Async( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ViewsClient.Delete.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ViewsClient.Delete.g.cs index 49a0ce2..6bddb5d 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ViewsClient.Delete.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ViewsClient.Delete.g.cs @@ -14,6 +14,7 @@ public partial class ViewsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -40,10 +41,12 @@ partial void ProcessDeleteResponse( /// Delete a specific view by ID. ///
/// + /// 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 DeleteAsync( string id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -58,22 +61,43 @@ partial void ProcessDeleteResponse( securityRequirements: s_DeleteSecurityRequirements, operationName: "DeleteAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/dm/views/{id}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/dm/views/{id}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -83,96 +107,255 @@ partial void ProcessDeleteResponse( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDeleteRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDeleteRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/dm/views/{id}/\"", + 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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/dm/views/{id}/\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessDeleteResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/dm/views/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessDeleteResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/dm/views/{id}/\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/dm/views/{id}/\"", + httpMethod: "DELETE", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.ViewsClient.DeleteAll.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ViewsClient.DeleteAll.g.cs index 6a32257..56119ef 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ViewsClient.DeleteAll.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ViewsClient.DeleteAll.g.cs @@ -14,6 +14,7 @@ public partial class ViewsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -40,10 +41,12 @@ partial void ProcessDeleteAllResponse( /// Delete all views for a specific project. /// /// + /// 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 DeleteAllAsync( int project, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -58,25 +61,46 @@ partial void ProcessDeleteAllResponse( securityRequirements: s_DeleteAllSecurityRequirements, operationName: "DeleteAllAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/dm/views/reset/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddRequiredParameter("project", project.ToString()!) - ; - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/dm/views/reset/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddRequiredParameter("project", project.ToString()!) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -86,96 +110,255 @@ partial void ProcessDeleteAllResponse( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDeleteAllRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - project: project); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDeleteAllRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + project: project); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteAll", + methodName: "DeleteAllAsync", + pathTemplate: "\"/api/dm/views/reset/\"", + 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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteAll", + methodName: "DeleteAllAsync", + pathTemplate: "\"/api/dm/views/reset/\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessDeleteAllResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteAll", + methodName: "DeleteAllAsync", + pathTemplate: "\"/api/dm/views/reset/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessDeleteAllResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteAll", + methodName: "DeleteAllAsync", + pathTemplate: "\"/api/dm/views/reset/\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteAll", + methodName: "DeleteAllAsync", + pathTemplate: "\"/api/dm/views/reset/\"", + httpMethod: "DELETE", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.ViewsClient.Get.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ViewsClient.Get.g.cs index bc7e5b8..3cee0cc 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ViewsClient.Get.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ViewsClient.Get.g.cs @@ -14,6 +14,7 @@ public partial class ViewsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,10 +46,12 @@ partial void ProcessGetResponseContent( /// Get the details about a specific view in the data manager /// /// + /// 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 GetAsync( string id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -63,22 +66,43 @@ partial void ProcessGetResponseContent( securityRequirements: s_GetSecurityRequirements, operationName: "GetAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/dm/views/{id}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/dm/views/{id}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -88,112 +112,271 @@ partial void ProcessGetResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/dm/views/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/dm/views/{id}/\"", + 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); - ProcessGetResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/dm/views/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.View.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.View.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGetResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/dm/views/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/dm/views/{id}/\"", + 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); + ProcessGetResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.View.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.View.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.ViewsClient.List2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ViewsClient.List2.g.cs index c403ec8..9b5a903 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ViewsClient.List2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ViewsClient.List2.g.cs @@ -14,6 +14,7 @@ public partial class ViewsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,10 +46,12 @@ partial void ProcessList2ResponseContent( /// List all views for a specific project. /// /// + /// 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> List2Async( int? project = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -63,25 +66,46 @@ partial void ProcessList2ResponseContent( securityRequirements: s_List2SecurityRequirements, operationName: "List2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/dm/views/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("project", project?.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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/dm/views/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("project", project?.ToString()) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -91,112 +115,271 @@ partial void ProcessList2ResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareList2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - project: project); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareList2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + project: project); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessList2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/dm/views/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/dm/views/\"", + 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); - ProcessList2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/dm/views/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessList2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/dm/views/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "\"/api/dm/views/\"", + 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); + ProcessList2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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 + (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.ViewsClient.Update.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ViewsClient.Update.g.cs index 8a95423..52adf9b 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ViewsClient.Update.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ViewsClient.Update.g.cs @@ -14,6 +14,7 @@ public partial class ViewsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -48,12 +49,14 @@ partial void ProcessUpdateResponseContent( /// /// /// + /// 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 UpdateAsync( string id, global::LabelStudio.ApiDmViewsPartialUpdateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -71,22 +74,43 @@ partial void ProcessUpdateResponseContent( securityRequirements: s_UpdateSecurityRequirements, operationName: "UpdateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/dm/views/{id}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/dm/views/{id}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -96,119 +120,278 @@ partial void ProcessUpdateResponseContent( __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); - PrepareUpdateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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::LabelStudio.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); + PrepareUpdateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessUpdateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/dm/views/{id}/\"", + 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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/dm/views/{id}/\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessUpdateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/dm/views/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.View.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.View.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessUpdateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/dm/views/{id}/\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/dm/views/{id}/\"", + httpMethod: "PATCH", + 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); + ProcessUpdateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.View.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.View.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 view
@@ -221,12 +404,14 @@ partial void ProcessUpdateResponseContent( /// /// Project ID /// + /// 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 UpdateAsync( string id, global::LabelStudio.ApiDmViewsPartialUpdateRequestData? data = default, int? project = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.ApiDmViewsPartialUpdateRequest @@ -238,6 +423,7 @@ partial void ProcessUpdateResponseContent( return await UpdateAsync( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ViewsClient.UpdateOrder.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ViewsClient.UpdateOrder.g.cs index c4909f1..56500e9 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ViewsClient.UpdateOrder.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ViewsClient.UpdateOrder.g.cs @@ -14,6 +14,7 @@ public partial class ViewsClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -40,11 +41,13 @@ partial void ProcessUpdateOrderResponse( /// Update the order field of views based on the provided list of view 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 UpdateOrderAsync( global::LabelStudio.ViewOrderRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -61,22 +64,43 @@ partial void ProcessUpdateOrderResponse( securityRequirements: s_UpdateOrderSecurityRequirements, operationName: "UpdateOrderAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/dm/views/order/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/dm/views/order/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -86,102 +110,261 @@ partial void ProcessUpdateOrderResponse( __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); - PrepareUpdateOrderRequest( - 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::LabelStudio.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); + PrepareUpdateOrderRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessUpdateOrderResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateOrder", + methodName: "UpdateOrderAsync", + pathTemplate: "\"/api/dm/views/order/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateOrder", + methodName: "UpdateOrderAsync", + pathTemplate: "\"/api/dm/views/order/\"", + 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); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateOrder", + methodName: "UpdateOrderAsync", + pathTemplate: "\"/api/dm/views/order/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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) + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessUpdateOrderResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateOrder", + methodName: "UpdateOrderAsync", + pathTemplate: "\"/api/dm/views/order/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateOrder", + methodName: "UpdateOrderAsync", + pathTemplate: "\"/api/dm/views/order/\"", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 order of views
@@ -191,11 +374,13 @@ partial void ProcessUpdateOrderResponse( /// A list of view IDs in the desired order. /// /// + /// 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 UpdateOrderAsync( global::System.Collections.Generic.IList ids, int project, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.ViewOrderRequest @@ -206,6 +391,7 @@ partial void ProcessUpdateOrderResponse( await UpdateOrderAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ViewsClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ViewsClient.g.cs index 9c34aee..bd78250 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ViewsClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ViewsClient.g.cs @@ -30,6 +30,9 @@ public sealed partial class ViewsClient : global::LabelStudio.IViewsClient, glob #if DEBUG = true; #endif + + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public ViewsClient( 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 ViewsClient. + /// 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 ViewsClient( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::LabelStudio.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::LabelStudio.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/LabelStudio/Generated/LabelStudio.Webhooks2Client.Create.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Webhooks2Client.Create.g.cs index 9b231d5..4d2fa3d 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Webhooks2Client.Create.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Webhooks2Client.Create.g.cs @@ -14,6 +14,7 @@ public partial class Webhooks2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,11 +46,13 @@ partial void ProcessCreateResponseContent( /// Create a webhook for your 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 CreateAsync( global::LabelStudio.WebhookRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -66,22 +69,43 @@ partial void ProcessCreateResponseContent( securityRequirements: s_CreateSecurityRequirements, operationName: "CreateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/webhooks/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/webhooks/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,118 +115,277 @@ partial void ProcessCreateResponseContent( __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::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCreateRequest( - 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); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/webhooks/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/webhooks/\"", + 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); - ProcessCreateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/webhooks/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.Webhook.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.Webhook.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessCreateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/webhooks/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/webhooks/\"", + 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); + ProcessCreateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.Webhook.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.Webhook.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 webhook
@@ -227,6 +410,7 @@ partial void ProcessCreateResponseContent( /// /// URL of webhook /// + /// 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 CreateAsync( @@ -237,6 +421,7 @@ partial void ProcessCreateResponseContent( int? project = default, bool? sendForAllActions = default, bool? sendPayload = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.WebhookRequest @@ -252,6 +437,7 @@ partial void ProcessCreateResponseContent( return await CreateAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.Webhooks2Client.Delete.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Webhooks2Client.Delete.g.cs index c9ba841..262a791 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Webhooks2Client.Delete.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Webhooks2Client.Delete.g.cs @@ -14,6 +14,7 @@ public partial class Webhooks2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -39,10 +40,12 @@ partial void ProcessDeleteResponse( /// Delete webhook info ///
/// + /// 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 DeleteAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -57,22 +60,43 @@ partial void ProcessDeleteResponse( securityRequirements: s_DeleteSecurityRequirements, operationName: "DeleteAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/webhooks/{id}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/webhooks/{id}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -82,96 +106,255 @@ partial void ProcessDeleteResponse( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDeleteRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDeleteRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/webhooks/{id}/\"", + 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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/webhooks/{id}/\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessDeleteResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/webhooks/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessDeleteResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/webhooks/{id}/\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/webhooks/{id}/\"", + httpMethod: "DELETE", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.Webhooks2Client.Get.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Webhooks2Client.Get.g.cs index efe898e..b1a4aab 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Webhooks2Client.Get.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Webhooks2Client.Get.g.cs @@ -14,6 +14,7 @@ public partial class Webhooks2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -44,10 +45,12 @@ partial void ProcessGetResponseContent( /// Get webhook info /// /// + /// 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 GetAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -62,22 +65,43 @@ partial void ProcessGetResponseContent( securityRequirements: s_GetSecurityRequirements, operationName: "GetAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/webhooks/{id}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/webhooks/{id}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -87,112 +111,271 @@ partial void ProcessGetResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/webhooks/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/webhooks/{id}/\"", + 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); - ProcessGetResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/webhooks/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.Webhook.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.Webhook.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGetResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/webhooks/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/webhooks/{id}/\"", + 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); + ProcessGetResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.Webhook.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.Webhook.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.Webhooks2Client.Info.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Webhooks2Client.Info.g.cs index f426029..65ed529 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Webhooks2Client.Info.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Webhooks2Client.Info.g.cs @@ -14,6 +14,7 @@ public partial class Webhooks2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -54,10 +55,12 @@ partial void ProcessInfoResponseContent( /// Get descriptions of all available webhook actions to set up webhooks. /// /// + /// 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( bool? organizationOnly = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -72,25 +75,46 @@ partial void ProcessInfoResponseContent( securityRequirements: s_InfoSecurityRequirements, operationName: "InfoAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/webhooks/info/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("organization-only", organizationOnly?.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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/webhooks/info/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("organization-only", organizationOnly?.ToString().ToLowerInvariant()) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,112 +124,271 @@ partial void ProcessInfoResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareInfoRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - organizationOnly: organizationOnly); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareInfoRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + organizationOnly: organizationOnly); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessInfoResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Info", + methodName: "InfoAsync", + pathTemplate: "\"/api/webhooks/info/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Info", + methodName: "InfoAsync", + pathTemplate: "\"/api/webhooks/info/\"", + 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); - ProcessInfoResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Info", + methodName: "InfoAsync", + pathTemplate: "\"/api/webhooks/info/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.ApiWebhooksInfoRetrieveResponse.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.ApiWebhooksInfoRetrieveResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessInfoResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Info", + methodName: "InfoAsync", + pathTemplate: "\"/api/webhooks/info/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Info", + methodName: "InfoAsync", + pathTemplate: "\"/api/webhooks/info/\"", + 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); + ProcessInfoResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.ApiWebhooksInfoRetrieveResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiWebhooksInfoRetrieveResponse.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.Webhooks2Client.List.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Webhooks2Client.List.g.cs index f91c896..3246c6d 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Webhooks2Client.List.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Webhooks2Client.List.g.cs @@ -14,6 +14,7 @@ public partial class Webhooks2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,10 +46,12 @@ partial void ProcessListResponseContent( /// List all webhooks set up for your 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> ListAsync( string? project = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -63,25 +66,46 @@ partial void ProcessListResponseContent( securityRequirements: s_ListSecurityRequirements, operationName: "ListAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/webhooks/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("project", project) - ; - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/webhooks/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("project", project) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -91,112 +115,271 @@ partial void ProcessListResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareListRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - project: project); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareListRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + project: project); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessListResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/webhooks/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/webhooks/\"", + 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); - ProcessListResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/webhooks/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessListResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/webhooks/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/webhooks/\"", + 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); + ProcessListResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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 + (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.Webhooks2Client.Update.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Webhooks2Client.Update.g.cs index e62428b..0ddadc1 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Webhooks2Client.Update.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Webhooks2Client.Update.g.cs @@ -14,6 +14,7 @@ public partial class Webhooks2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -47,12 +48,14 @@ partial void ProcessUpdateResponseContent( /// /// /// + /// 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 UpdateAsync( int id, global::LabelStudio.PatchedWebhookSerializerForUpdateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -70,22 +73,43 @@ partial void ProcessUpdateResponseContent( securityRequirements: s_UpdateSecurityRequirements, operationName: "UpdateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/webhooks/{id}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/webhooks/{id}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -95,119 +119,278 @@ partial void ProcessUpdateResponseContent( __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); - PrepareUpdateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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::LabelStudio.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); + PrepareUpdateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessUpdateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/webhooks/{id}/\"", + 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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/webhooks/{id}/\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessUpdateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/webhooks/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.WebhookSerializerForUpdate.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.WebhookSerializerForUpdate.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessUpdateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/webhooks/{id}/\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/webhooks/{id}/\"", + httpMethod: "PATCH", + 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); + ProcessUpdateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.WebhookSerializerForUpdate.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.WebhookSerializerForUpdate.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 webhook info @@ -231,6 +414,7 @@ partial void ProcessUpdateResponseContent( /// /// URL of webhook /// + /// 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 UpdateAsync( @@ -241,6 +425,7 @@ partial void ProcessUpdateResponseContent( bool? sendForAllActions = default, bool? sendPayload = default, string? url = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.PatchedWebhookSerializerForUpdateRequest @@ -256,6 +441,7 @@ partial void ProcessUpdateResponseContent( return await UpdateAsync( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.Webhooks2Client.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Webhooks2Client.g.cs index ef675ed..2c7311e 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Webhooks2Client.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Webhooks2Client.g.cs @@ -30,6 +30,9 @@ public sealed partial class Webhooks2Client : global::LabelStudio.IWebhooks2Clie #if DEBUG = true; #endif + + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public Webhooks2Client( 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 Webhooks2Client. + /// 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 Webhooks2Client( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::LabelStudio.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::LabelStudio.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/LabelStudio/Generated/LabelStudio.WebhooksClient.ApiWebhooksUpdate.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.WebhooksClient.ApiWebhooksUpdate.g.cs index 376192a..6c948ef 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.WebhooksClient.ApiWebhooksUpdate.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.WebhooksClient.ApiWebhooksUpdate.g.cs @@ -14,6 +14,7 @@ public partial class WebhooksClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -47,12 +48,14 @@ partial void ProcessApiWebhooksUpdateResponseContent( /// /// /// + /// 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 ApiWebhooksUpdateAsync( int id, global::LabelStudio.WebhookSerializerForUpdateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -70,22 +73,43 @@ partial void ProcessApiWebhooksUpdateResponseContent( securityRequirements: s_ApiWebhooksUpdateSecurityRequirements, operationName: "ApiWebhooksUpdateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/webhooks/{id}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/webhooks/{id}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -95,119 +119,278 @@ partial void ProcessApiWebhooksUpdateResponseContent( __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); - PrepareApiWebhooksUpdateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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::LabelStudio.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); + PrepareApiWebhooksUpdateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessApiWebhooksUpdateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiWebhooksUpdate", + methodName: "ApiWebhooksUpdateAsync", + pathTemplate: "$\"/api/webhooks/{id}/\"", + 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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiWebhooksUpdate", + methodName: "ApiWebhooksUpdateAsync", + pathTemplate: "$\"/api/webhooks/{id}/\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessApiWebhooksUpdateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiWebhooksUpdate", + methodName: "ApiWebhooksUpdateAsync", + pathTemplate: "$\"/api/webhooks/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.WebhookSerializerForUpdate.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.WebhookSerializerForUpdate.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessApiWebhooksUpdateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiWebhooksUpdate", + methodName: "ApiWebhooksUpdateAsync", + pathTemplate: "$\"/api/webhooks/{id}/\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ApiWebhooksUpdate", + methodName: "ApiWebhooksUpdateAsync", + pathTemplate: "$\"/api/webhooks/{id}/\"", + httpMethod: "PUT", + 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); + ProcessApiWebhooksUpdateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.WebhookSerializerForUpdate.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.WebhookSerializerForUpdate.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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(); + } } /// /// Save webhook info @@ -231,6 +414,7 @@ partial void ProcessApiWebhooksUpdateResponseContent( /// /// URL of webhook /// + /// 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 ApiWebhooksUpdateAsync( @@ -241,6 +425,7 @@ partial void ProcessApiWebhooksUpdateResponseContent( bool? isActive = default, bool? sendForAllActions = default, bool? sendPayload = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.WebhookSerializerForUpdateRequest @@ -256,6 +441,7 @@ partial void ProcessApiWebhooksUpdateResponseContent( return await ApiWebhooksUpdateAsync( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.WebhooksClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.WebhooksClient.g.cs index 67ca9f9..10277af 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.WebhooksClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.WebhooksClient.g.cs @@ -30,6 +30,9 @@ public sealed partial class WebhooksClient : global::LabelStudio.IWebhooksClient #if DEBUG = true; #endif + + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public WebhooksClient( 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 WebhooksClient. + /// 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 WebhooksClient( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::LabelStudio.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::LabelStudio.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/LabelStudio/Generated/LabelStudio.Workspaces2Client.Create.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Workspaces2Client.Create.g.cs index 4c9a040..ed8f7a1 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Workspaces2Client.Create.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Workspaces2Client.Create.g.cs @@ -14,6 +14,7 @@ public partial class Workspaces2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,11 +52,13 @@ partial void ProcessCreateResponseContent( /// Create a new workspace. Workspaces in Label Studio let you organize your projects and users into separate spaces. This is useful for managing different teams, departments, or projects within your organization. For more information, see the [Workspaces documentation](https://docs.humansignal.com/workspaces). /// /// + /// 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 CreateAsync( global::LabelStudio.WorkspaceRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -72,22 +75,43 @@ partial void ProcessCreateResponseContent( securityRequirements: s_CreateSecurityRequirements, operationName: "CreateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/workspaces/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/workspaces/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -97,118 +121,277 @@ partial void ProcessCreateResponseContent( __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::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCreateRequest( - 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); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/workspaces/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/workspaces/\"", + 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); - ProcessCreateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/workspaces/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.Workspace.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.Workspace.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessCreateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/workspaces/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create", + methodName: "CreateAsync", + pathTemplate: "\"/api/workspaces/\"", + 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); + ProcessCreateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.Workspace.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.Workspace.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 workspace
@@ -235,6 +418,7 @@ partial void ProcessCreateResponseContent( /// /// Workspace Name /// + /// 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 CreateAsync( @@ -243,6 +427,7 @@ partial void ProcessCreateResponseContent( string? description = default, bool? isArchived = default, bool? isPersonal = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.WorkspaceRequest @@ -256,6 +441,7 @@ partial void ProcessCreateResponseContent( return await CreateAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.Workspaces2Client.Delete.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Workspaces2Client.Delete.g.cs index be3ea6a..839fe5e 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Workspaces2Client.Delete.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Workspaces2Client.Delete.g.cs @@ -14,6 +14,7 @@ public partial class Workspaces2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -46,10 +47,12 @@ partial void ProcessDeleteResponse( /// Delete a specific workspace by ID. ///
/// + /// 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 DeleteAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -64,22 +67,43 @@ partial void ProcessDeleteResponse( securityRequirements: s_DeleteSecurityRequirements, operationName: "DeleteAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/workspaces/{id}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/workspaces/{id}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -89,96 +113,255 @@ partial void ProcessDeleteResponse( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDeleteRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDeleteRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/workspaces/{id}/\"", + 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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/workspaces/{id}/\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessDeleteResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/workspaces/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessDeleteResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/workspaces/{id}/\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete", + methodName: "DeleteAsync", + pathTemplate: "$\"/api/workspaces/{id}/\"", + httpMethod: "DELETE", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.Workspaces2Client.Get.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Workspaces2Client.Get.g.cs index 898339f..37f2173 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Workspaces2Client.Get.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Workspaces2Client.Get.g.cs @@ -14,6 +14,7 @@ public partial class Workspaces2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,10 +52,12 @@ partial void ProcessGetResponseContent( /// Retrieve details for a specific workspace by ID. /// /// + /// 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 GetAsync( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -69,22 +72,43 @@ partial void ProcessGetResponseContent( securityRequirements: s_GetSecurityRequirements, operationName: "GetAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/workspaces/{id}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/workspaces/{id}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,112 +118,271 @@ partial void ProcessGetResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/workspaces/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/workspaces/{id}/\"", + 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); - ProcessGetResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/workspaces/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.Workspace.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.Workspace.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGetResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/workspaces/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Get", + methodName: "GetAsync", + pathTemplate: "$\"/api/workspaces/{id}/\"", + 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); + ProcessGetResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.Workspace.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.Workspace.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.Workspaces2Client.List.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Workspaces2Client.List.g.cs index eee977b..49c54cf 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Workspaces2Client.List.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Workspaces2Client.List.g.cs @@ -14,6 +14,7 @@ public partial class Workspaces2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -60,6 +61,7 @@ partial void ProcessListResponseContent( /// /// /// + /// 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> ListAsync( @@ -67,6 +69,7 @@ partial void ProcessListResponseContent( bool? isArchived = default, bool? isPersonal = default, string? ordering = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -84,28 +87,49 @@ partial void ProcessListResponseContent( securityRequirements: s_ListSecurityRequirements, operationName: "ListAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: "/api/workspaces/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("include_all_workspaces", includeAllWorkspaces?.ToString().ToLowerInvariant()) - .AddOptionalParameter("is_archived", isArchived?.ToString().ToLowerInvariant()) - .AddOptionalParameter("is_personal", isPersonal?.ToString().ToLowerInvariant()) - .AddOptionalParameter("ordering", ordering) - ; - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: "/api/workspaces/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("include_all_workspaces", includeAllWorkspaces?.ToString().ToLowerInvariant()) + .AddOptionalParameter("is_archived", isArchived?.ToString().ToLowerInvariant()) + .AddOptionalParameter("is_personal", isPersonal?.ToString().ToLowerInvariant()) + .AddOptionalParameter("ordering", ordering) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -115,115 +139,274 @@ partial void ProcessListResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareListRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - includeAllWorkspaces: includeAllWorkspaces, - isArchived: isArchived, - isPersonal: isPersonal, - ordering: ordering); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareListRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + includeAllWorkspaces: includeAllWorkspaces, + isArchived: isArchived, + isPersonal: isPersonal, + ordering: ordering); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessListResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/workspaces/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/workspaces/\"", + 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); - ProcessListResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/workspaces/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessListResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/workspaces/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List", + methodName: "ListAsync", + pathTemplate: "\"/api/workspaces/\"", + 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); + ProcessListResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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 + (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.Workspaces2Client.Update.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Workspaces2Client.Update.g.cs index 5d68c87..c7446f3 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Workspaces2Client.Update.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Workspaces2Client.Update.g.cs @@ -14,6 +14,7 @@ public partial class Workspaces2Client { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -54,12 +55,14 @@ partial void ProcessUpdateResponseContent( /// /// /// + /// 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 UpdateAsync( int id, global::LabelStudio.PatchedWorkspaceRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -77,22 +80,43 @@ partial void ProcessUpdateResponseContent( securityRequirements: s_UpdateSecurityRequirements, operationName: "UpdateAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/workspaces/{id}/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/workspaces/{id}/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -102,119 +126,278 @@ partial void ProcessUpdateResponseContent( __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); - PrepareUpdateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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::LabelStudio.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); + PrepareUpdateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessUpdateResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/workspaces/{id}/\"", + 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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/workspaces/{id}/\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessUpdateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/workspaces/{id}/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.Workspace.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.Workspace.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessUpdateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/workspaces/{id}/\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Update", + methodName: "UpdateAsync", + pathTemplate: "$\"/api/workspaces/{id}/\"", + httpMethod: "PATCH", + 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); + ProcessUpdateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.Workspace.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.Workspace.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 workspace
@@ -242,6 +425,7 @@ partial void ProcessUpdateResponseContent( /// /// Workspace Name /// + /// 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 UpdateAsync( @@ -251,6 +435,7 @@ partial void ProcessUpdateResponseContent( bool? isArchived = default, bool? isPersonal = default, string? title = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.PatchedWorkspaceRequest @@ -265,6 +450,7 @@ partial void ProcessUpdateResponseContent( return await UpdateAsync( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.Workspaces2Client.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Workspaces2Client.g.cs index e4dd939..93d390e 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Workspaces2Client.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Workspaces2Client.g.cs @@ -30,6 +30,9 @@ public sealed partial class Workspaces2Client : global::LabelStudio.IWorkspaces2 #if DEBUG = true; #endif + + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public Workspaces2Client( 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 Workspaces2Client. + /// 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 Workspaces2Client( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::LabelStudio.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::LabelStudio.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/LabelStudio/Generated/LabelStudio.WorkspacesClient.Add.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.WorkspacesClient.Add.g.cs index 8c80a42..aa70aba 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.WorkspacesClient.Add.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.WorkspacesClient.Add.g.cs @@ -14,6 +14,7 @@ public partial class WorkspacesClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -49,12 +50,14 @@ partial void ProcessAddResponse( ///
/// /// + /// 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 AddAsync( int id, global::LabelStudio.WorkspaceProjectsRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -72,22 +75,43 @@ partial void ProcessAddResponse( securityRequirements: s_AddSecurityRequirements, operationName: "AddAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/workspaces/{id}/projects/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/workspaces/{id}/projects/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -97,103 +121,262 @@ partial void ProcessAddResponse( __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); - PrepareAddRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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::LabelStudio.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); + PrepareAddRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessAddResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Add", + methodName: "AddAsync", + pathTemplate: "$\"/api/workspaces/{id}/projects/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Add", + methodName: "AddAsync", + pathTemplate: "$\"/api/workspaces/{id}/projects/\"", + 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); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Add", + methodName: "AddAsync", + pathTemplate: "$\"/api/workspaces/{id}/projects/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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(); + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessAddResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Add", + methodName: "AddAsync", + pathTemplate: "$\"/api/workspaces/{id}/projects/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Add", + methodName: "AddAsync", + pathTemplate: "$\"/api/workspaces/{id}/projects/\"", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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(); + } } /// /// ✨ Add workspace project
@@ -209,11 +392,13 @@ partial void ProcessAddResponse( /// /// Project ID /// + /// 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 AddAsync( int id, int project, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.WorkspaceProjectsRequest @@ -224,6 +409,7 @@ partial void ProcessAddResponse( await AddAsync( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.WorkspacesClient.Create2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.WorkspacesClient.Create2.g.cs index a8292bc..9318b4d 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.WorkspacesClient.Create2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.WorkspacesClient.Create2.g.cs @@ -14,6 +14,7 @@ public partial class WorkspacesClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -54,12 +55,14 @@ partial void ProcessCreate2ResponseContent( ///
/// /// + /// 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 Create2Async( int id, global::LabelStudio.WorkspaceMemberCreateRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -77,22 +80,43 @@ partial void ProcessCreate2ResponseContent( securityRequirements: s_Create2SecurityRequirements, operationName: "Create2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/workspaces/{id}/memberships/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/workspaces/{id}/memberships/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -102,119 +126,278 @@ partial void ProcessCreate2ResponseContent( __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); - PrepareCreate2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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::LabelStudio.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); + PrepareCreate2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreate2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "$\"/api/workspaces/{id}/memberships/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "$\"/api/workspaces/{id}/memberships/\"", + 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); - ProcessCreate2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "$\"/api/workspaces/{id}/memberships/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.WorkspaceMemberCreate.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.WorkspaceMemberCreate.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessCreate2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "$\"/api/workspaces/{id}/memberships/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Create2", + methodName: "Create2Async", + pathTemplate: "$\"/api/workspaces/{id}/memberships/\"", + 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); + ProcessCreate2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.WorkspaceMemberCreate.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.WorkspaceMemberCreate.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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 workspace membership
@@ -233,12 +416,14 @@ partial void ProcessCreate2ResponseContent( /// /// Workspace ID /// + /// 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 Create2Async( int id, int user, int? workspace = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.WorkspaceMemberCreateRequest @@ -250,6 +435,7 @@ partial void ProcessCreate2ResponseContent( return await Create2Async( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.WorkspacesClient.Delete2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.WorkspacesClient.Delete2.g.cs index e1d1afa..077400d 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.WorkspacesClient.Delete2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.WorkspacesClient.Delete2.g.cs @@ -14,6 +14,7 @@ public partial class WorkspacesClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -49,11 +50,13 @@ partial void ProcessDelete2Response( ///
/// /// + /// 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 Delete2Async( int id, int? userId = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -69,25 +72,46 @@ partial void ProcessDelete2Response( securityRequirements: s_Delete2SecurityRequirements, operationName: "Delete2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/workspaces/{id}/memberships/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("user_id", userId?.ToString()) - ; - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/workspaces/{id}/memberships/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("user_id", userId?.ToString()) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -97,97 +121,256 @@ partial void ProcessDelete2Response( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDelete2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - userId: userId); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDelete2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + userId: userId); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/workspaces/{id}/memberships/\"", + 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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/workspaces/{id}/memberships/\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessDelete2Response( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/workspaces/{id}/memberships/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessDelete2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/workspaces/{id}/memberships/\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete2", + methodName: "Delete2Async", + pathTemplate: "$\"/api/workspaces/{id}/memberships/\"", + httpMethod: "DELETE", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.WorkspacesClient.Delete3.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.WorkspacesClient.Delete3.g.cs index 1a55257..e6b6cbc 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.WorkspacesClient.Delete3.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.WorkspacesClient.Delete3.g.cs @@ -14,6 +14,7 @@ public partial class WorkspacesClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -66,6 +67,7 @@ partial void ProcessDelete3ResponseContent( /// /// /// + /// 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 Delete3Async( @@ -75,6 +77,7 @@ partial void ProcessDelete3ResponseContent( string? ids = default, string? included = default, string? search = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -94,29 +97,50 @@ partial void ProcessDelete3ResponseContent( securityRequirements: s_Delete3SecurityRequirements, operationName: "Delete3Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/workspaces/{id}/memberships/bulk/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("all", all?.ToString().ToLowerInvariant()) - .AddOptionalParameter("excluded", excluded) - .AddOptionalParameter("ids", ids) - .AddOptionalParameter("included", included) - .AddOptionalParameter("search", search) - ; - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/workspaces/{id}/memberships/bulk/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("all", all?.ToString().ToLowerInvariant()) + .AddOptionalParameter("excluded", excluded) + .AddOptionalParameter("ids", ids) + .AddOptionalParameter("included", included) + .AddOptionalParameter("search", search) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -126,117 +150,276 @@ partial void ProcessDelete3ResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDelete3Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - all: all, - excluded: excluded, - id: id, - ids: ids, - included: included, - search: search); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDelete3Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + all: all, + excluded: excluded, + id: id, + ids: ids, + included: included, + search: search); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessDelete3Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete3", + methodName: "Delete3Async", + pathTemplate: "$\"/api/workspaces/{id}/memberships/bulk/\"", + 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 + { + __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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete3", + methodName: "Delete3Async", + pathTemplate: "$\"/api/workspaces/{id}/memberships/bulk/\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessDelete3ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete3", + methodName: "Delete3Async", + pathTemplate: "$\"/api/workspaces/{id}/memberships/bulk/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.ApiWorkspacesMembershipsBulkDestroyResponse.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.ApiWorkspacesMembershipsBulkDestroyResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessDelete3Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete3", + methodName: "Delete3Async", + pathTemplate: "$\"/api/workspaces/{id}/memberships/bulk/\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Delete3", + methodName: "Delete3Async", + pathTemplate: "$\"/api/workspaces/{id}/memberships/bulk/\"", + httpMethod: "DELETE", + 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); + ProcessDelete3ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.ApiWorkspacesMembershipsBulkDestroyResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiWorkspacesMembershipsBulkDestroyResponse.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.WorkspacesClient.List2.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.WorkspacesClient.List2.g.cs index ede15be..392a66b 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.WorkspacesClient.List2.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.WorkspacesClient.List2.g.cs @@ -14,6 +14,7 @@ public partial class WorkspacesClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,10 +52,12 @@ partial void ProcessList2ResponseContent( /// Get a list of all members in a specific workspace. /// /// + /// 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> List2Async( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -69,22 +72,43 @@ partial void ProcessList2ResponseContent( securityRequirements: s_List2SecurityRequirements, operationName: "List2Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/workspaces/{id}/memberships/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/workspaces/{id}/memberships/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,112 +118,271 @@ partial void ProcessList2ResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareList2Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareList2Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessList2Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "$\"/api/workspaces/{id}/memberships/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "$\"/api/workspaces/{id}/memberships/\"", + 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); - ProcessList2ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "$\"/api/workspaces/{id}/memberships/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessList2Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "$\"/api/workspaces/{id}/memberships/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List2", + methodName: "List2Async", + pathTemplate: "$\"/api/workspaces/{id}/memberships/\"", + 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); + ProcessList2ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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 + (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.WorkspacesClient.List3.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.WorkspacesClient.List3.g.cs index 57e0209..d899485 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.WorkspacesClient.List3.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.WorkspacesClient.List3.g.cs @@ -14,6 +14,7 @@ public partial class WorkspacesClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -63,6 +64,7 @@ partial void ProcessList3ResponseContent( /// /// /// + /// 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 List3Async( @@ -71,6 +73,7 @@ partial void ProcessList3ResponseContent( int? page = default, int? pageSize = default, string? search = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -89,28 +92,49 @@ partial void ProcessList3ResponseContent( securityRequirements: s_List3SecurityRequirements, operationName: "List3Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/workspaces/{id}/memberships/paginated/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("ids", ids) - .AddOptionalParameter("page", page?.ToString()) - .AddOptionalParameter("page_size", pageSize?.ToString()) - .AddOptionalParameter("search", search) - ; - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/workspaces/{id}/memberships/paginated/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("ids", ids) + .AddOptionalParameter("page", page?.ToString()) + .AddOptionalParameter("page_size", pageSize?.ToString()) + .AddOptionalParameter("search", search) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -120,116 +144,275 @@ partial void ProcessList3ResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareList3Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - ids: ids, - page: page, - pageSize: pageSize, - search: search); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareList3Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + ids: ids, + page: page, + pageSize: pageSize, + search: search); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessList3Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List3", + methodName: "List3Async", + pathTemplate: "$\"/api/workspaces/{id}/memberships/paginated/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List3", + methodName: "List3Async", + pathTemplate: "$\"/api/workspaces/{id}/memberships/paginated/\"", + 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); - ProcessList3ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List3", + methodName: "List3Async", + pathTemplate: "$\"/api/workspaces/{id}/memberships/paginated/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.PaginatedLseUserList.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.PaginatedLseUserList.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessList3Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List3", + methodName: "List3Async", + pathTemplate: "$\"/api/workspaces/{id}/memberships/paginated/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List3", + methodName: "List3Async", + pathTemplate: "$\"/api/workspaces/{id}/memberships/paginated/\"", + 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); + ProcessList3ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.PaginatedLseUserList.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.PaginatedLseUserList.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.WorkspacesClient.List4.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.WorkspacesClient.List4.g.cs index 52c5c8d..8dc1091 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.WorkspacesClient.List4.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.WorkspacesClient.List4.g.cs @@ -14,6 +14,7 @@ public partial class WorkspacesClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,10 +52,12 @@ partial void ProcessList4ResponseContent( /// Retrieve a list of all projects in a specific workspace. /// /// + /// 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> List4Async( int id, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -69,22 +72,43 @@ partial void ProcessList4ResponseContent( securityRequirements: s_List4SecurityRequirements, operationName: "List4Async"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/workspaces/{id}/projects/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/workspaces/{id}/projects/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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,112 +118,271 @@ partial void ProcessList4ResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareList4Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareList4Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessList4Response( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List4", + methodName: "List4Async", + pathTemplate: "$\"/api/workspaces/{id}/projects/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List4", + methodName: "List4Async", + pathTemplate: "$\"/api/workspaces/{id}/projects/\"", + 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); - ProcessList4ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List4", + methodName: "List4Async", + pathTemplate: "$\"/api/workspaces/{id}/projects/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 - (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessList4Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List4", + methodName: "List4Async", + pathTemplate: "$\"/api/workspaces/{id}/projects/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "List4", + methodName: "List4Async", + pathTemplate: "$\"/api/workspaces/{id}/projects/\"", + 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); + ProcessList4ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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 + (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.WorkspacesClient.Post.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.WorkspacesClient.Post.g.cs index d3ee57f..334ac9b 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.WorkspacesClient.Post.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.WorkspacesClient.Post.g.cs @@ -14,6 +14,7 @@ public partial class WorkspacesClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -54,12 +55,14 @@ partial void ProcessPostResponseContent( /// /// /// + /// 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 PostAsync( int id, global::LabelStudio.WorkspaceMemberBulkAssignRequest request, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -77,22 +80,43 @@ partial void ProcessPostResponseContent( securityRequirements: s_PostSecurityRequirements, operationName: "PostAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/workspaces/{id}/memberships/bulk/", - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/workspaces/{id}/memberships/bulk/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -102,119 +126,278 @@ partial void ProcessPostResponseContent( __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); - PreparePostRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - 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::LabelStudio.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); + PreparePostRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessPostResponse( - 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::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Post", + methodName: "PostAsync", + pathTemplate: "$\"/api/workspaces/{id}/memberships/bulk/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Post", + methodName: "PostAsync", + pathTemplate: "$\"/api/workspaces/{id}/memberships/bulk/\"", + 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); - ProcessPostResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Post", + methodName: "PostAsync", + pathTemplate: "$\"/api/workspaces/{id}/memberships/bulk/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::LabelStudio.ApiWorkspacesMembershipsBulkCreateResponse.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::LabelStudio.ApiException( - message: __content ?? __response.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::LabelStudio.ApiWorkspacesMembershipsBulkCreateResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessPostResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Post", + methodName: "PostAsync", + pathTemplate: "$\"/api/workspaces/{id}/memberships/bulk/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Post", + methodName: "PostAsync", + pathTemplate: "$\"/api/workspaces/{id}/memberships/bulk/\"", + 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); + ProcessPostResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::LabelStudio.ApiWorkspacesMembershipsBulkCreateResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiWorkspacesMembershipsBulkCreateResponse.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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(); + } } /// /// ✨ Bulk assign workspace members
@@ -236,6 +419,7 @@ partial void ProcessPostResponseContent( /// /// Included user 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 PostAsync( @@ -243,6 +427,7 @@ partial void ProcessPostResponseContent( bool all, global::System.Collections.Generic.IList? excluded = default, global::System.Collections.Generic.IList? included = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::LabelStudio.WorkspaceMemberBulkAssignRequest @@ -255,6 +440,7 @@ partial void ProcessPostResponseContent( return await PostAsync( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/LabelStudio/Generated/LabelStudio.WorkspacesClient.Remove.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.WorkspacesClient.Remove.g.cs index ee45527..de39073 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.WorkspacesClient.Remove.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.WorkspacesClient.Remove.g.cs @@ -14,6 +14,7 @@ public partial class WorkspacesClient { new global::LabelStudio.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "Token", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -49,11 +50,13 @@ partial void ProcessRemoveResponse( ///
/// /// + /// 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 RemoveAsync( int id, int? project = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -69,25 +72,46 @@ partial void ProcessRemoveResponse( securityRequirements: s_RemoveSecurityRequirements, operationName: "RemoveAsync"); - var __pathBuilder = new global::LabelStudio.PathBuilder( - path: $"/api/workspaces/{id}/projects/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("project", project?.ToString()) - ; - 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::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/workspaces/{id}/projects/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("project", project?.ToString()) + ; + var __path = __pathBuilder.ToString(); + __path = global::LabelStudio.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, @@ -97,97 +121,256 @@ partial void ProcessRemoveResponse( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareRemoveRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - project: project); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareRemoveRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + project: project); - using var __response = await HttpClient.SendAsync( + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Remove", + methodName: "RemoveAsync", + pathTemplate: "$\"/api/workspaces/{id}/projects/\"", + 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 + { + __response = await HttpClient.SendAsync( request: __httpRequest, completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Remove", + methodName: "RemoveAsync", + pathTemplate: "$\"/api/workspaces/{id}/projects/\"", + 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; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessRemoveResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Remove", + methodName: "RemoveAsync", + pathTemplate: "$\"/api/workspaces/{id}/projects/\"", + 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::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + break; + } - try + if (__response == null) { - __response.EnsureSuccessStatusCode(); - + throw new global::System.InvalidOperationException("No response received."); } - catch (global::System.Exception __ex) + + using (__response) { - throw new global::LabelStudio.ApiException( - message: __content ?? __response.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 + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessRemoveResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Remove", + methodName: "RemoveAsync", + pathTemplate: "$\"/api/workspaces/{id}/projects/\"", + 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 { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Remove", + methodName: "RemoveAsync", + pathTemplate: "$\"/api/workspaces/{id}/projects/\"", + httpMethod: "DELETE", + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( + message: __content ?? __response.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::LabelStudio.ApiException( - message: __content ?? __response.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/LabelStudio/Generated/LabelStudio.WorkspacesClient.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.WorkspacesClient.g.cs index 15b0958..904a690 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.WorkspacesClient.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.WorkspacesClient.g.cs @@ -30,6 +30,9 @@ public sealed partial class WorkspacesClient : global::LabelStudio.IWorkspacesCl #if DEBUG = true; #endif + + /// + public global::LabelStudio.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public WorkspacesClient( 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 WorkspacesClient. + /// 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 WorkspacesClient( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::LabelStudio.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::LabelStudio.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient);