From ed9593402054630c4a9a9bafa812caf20c67738e Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 26 Oct 2026 03:35:15 +0000 Subject: [PATCH] feat: Updated OpenAPI spec --- .../LabelStudio.Comments2Client.Export.g.cs | 364 ++++++++++++++++ .../LabelStudio.ExportClient.Download.g.cs | 344 +++++++++++++++ .../LabelStudio.IComments2Client.Export.g.cs | 31 ++ .../LabelStudio.IExportClient.Download.g.cs | 22 + ...ResourcesClient.ExportUserProgressCsv.g.cs | 27 ++ ...LabelStudio.IProjectsClient.ExportCsv.g.cs | 41 ++ ...ResourcesClient.ExportUserProgressCsv.g.cs | 356 ++++++++++++++++ .../LabelStudio.ProjectsClient.ExportCsv.g.cs | 391 ++++++++++++++++++ .../Generated/LabelStudio.ResponseStream.g.cs | 66 ++- 9 files changed, 1620 insertions(+), 22 deletions(-) diff --git a/src/libs/LabelStudio/Generated/LabelStudio.Comments2Client.Export.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.Comments2Client.Export.g.cs index c993e815..92d9697b 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.Comments2Client.Export.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.Comments2Client.Export.g.cs @@ -408,6 +408,370 @@ partial void ProcessExportResponseContent( return new global::LabelStudio.ResponseStream(__response, __content); } + catch (global::System.OperationCanceledException) + { + throw; + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw global::LabelStudio.ApiException.Create( + statusCode: __response.StatusCode, + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + responseBody: __content, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + + } + catch + { + __response.Dispose(); + throw; + } + } + finally + { + __httpRequest?.Dispose(); + } + } + /// + /// ✨ Export comments to CSV
+ /// <Card href="https://humansignal.com/goenterprise">
+ /// <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
+ /// <p style="margin-top: 10px; font-size: 14px;">
+ /// This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
+ /// </p>
+ /// </Card>
+ /// Export comments to CSV file + ///
+ /// + /// + /// + /// + /// Default Value: false + /// + /// + /// + /// The response metadata and an unbuffered body stream. The caller must dispose Body to release the HTTP 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> ExportAsStreamAsResponseAsync( + int? annotation = default, + string? annotators = default, + int? draft = default, + bool? expandCreatedBy = default, + string? projects = default, + string? tz = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + PrepareArguments( + client: HttpClient); + PrepareExportArguments( + httpClient: HttpClient, + annotation: ref annotation, + annotators: ref annotators, + draft: ref draft, + expandCreatedBy: ref expandCreatedBy, + projects: ref projects, + tz: ref tz); + + + var __authorizations = global::LabelStudio.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_ExportSecurityRequirements, + operationName: "ExportAsync"); + + using var __timeoutCancellationTokenSource = global::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = 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; +#endif + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __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); + + 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: "Export", + methodName: "ExportAsync", + pathTemplate: "\"/api/comments/export/\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseHeadersRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::LabelStudio.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + 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 ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::LabelStudio.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + 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 ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + try + { + + 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 ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + 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 ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + + try + { + __response.EnsureSuccessStatusCode(); + + var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return new global::LabelStudio.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::LabelStudio.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: new global::LabelStudio.ResponseStream(__response, __content)); + } + catch (global::System.OperationCanceledException) + { + throw; + } catch (global::System.Exception __ex) { string? __content = null; diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ExportClient.Download.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ExportClient.Download.g.cs index 789366bb..006b7e8d 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ExportClient.Download.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ExportClient.Download.g.cs @@ -370,6 +370,350 @@ partial void ProcessDownloadResponseContent( return new global::LabelStudio.ResponseStream(__response, __content); } + catch (global::System.OperationCanceledException) + { + throw; + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw global::LabelStudio.ApiException.Create( + statusCode: __response.StatusCode, + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + responseBody: __content, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + + } + catch + { + __response.Dispose(); + throw; + } + } + finally + { + __httpRequest?.Dispose(); + } + } + /// + /// Download export snapshot as file in specified format
+ /// Download an export file in the specified format for a specific project. Specify the project ID with the `id`
+ /// parameter in the path and the ID of the export file you want to download using the `export_pk` parameter
+ /// in the path.
+ /// Get the `export_pk` from the response of the request to [Create new export](api:POST/api/projects/{id}/exports/)
+ /// or after [listing export files](api:GET/api/projects/{id}/exports/).
+ /// + ///
+ /// + /// + /// + /// The response metadata and an unbuffered body stream. The caller must dispose Body to release the HTTP 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> DownloadAsStreamAsResponseAsync( + int exportPk, + int id, + string? exportType = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + PrepareArguments( + client: HttpClient); + PrepareDownloadArguments( + httpClient: HttpClient, + exportType: ref exportType, + exportPk: ref exportPk, + id: ref id); + + + var __authorizations = global::LabelStudio.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_DownloadSecurityRequirements, + operationName: "DownloadAsync"); + + using var __timeoutCancellationTokenSource = global::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = 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; +#endif + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __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); + + 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: "$\"/api/projects/{id}/exports/{exportPk}/download\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseHeadersRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::LabelStudio.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + 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 ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::LabelStudio.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + 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 ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + try + { + + 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 ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + 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 ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + + try + { + __response.EnsureSuccessStatusCode(); + + var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return new global::LabelStudio.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::LabelStudio.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: new global::LabelStudio.ResponseStream(__response, __content)); + } + catch (global::System.OperationCanceledException) + { + throw; + } catch (global::System.Exception __ex) { string? __content = null; diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IComments2Client.Export.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IComments2Client.Export.g.cs index d22fa0fd..8a309430 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IComments2Client.Export.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IComments2Client.Export.g.cs @@ -82,6 +82,37 @@ public partial interface IComments2Client /// /// /// + /// The response metadata and an unbuffered body stream. The caller must dispose Body to release the HTTP 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> ExportAsStreamAsResponseAsync( + int? annotation = default, + string? annotators = default, + int? draft = default, + bool? expandCreatedBy = default, + string? projects = default, + string? tz = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// ✨ Export comments to CSV
+ /// <Card href="https://humansignal.com/goenterprise">
+ /// <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
+ /// <p style="margin-top: 10px; font-size: 14px;">
+ /// This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
+ /// </p>
+ /// </Card>
+ /// Export comments to CSV file + ///
+ /// + /// + /// + /// + /// Default Value: false + /// + /// + /// /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IExportClient.Download.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IExportClient.Download.g.cs index 0bbac077..79082515 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IExportClient.Download.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IExportClient.Download.g.cs @@ -58,6 +58,28 @@ public partial interface IExportClient /// /// /// + /// The response metadata and an unbuffered body stream. The caller must dispose Body to release the HTTP 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> DownloadAsStreamAsResponseAsync( + int exportPk, + int id, + string? exportType = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Download export snapshot as file in specified format
+ /// Download an export file in the specified format for a specific project. Specify the project ID with the `id`
+ /// parameter in the path and the ID of the export file you want to download using the `export_pk` parameter
+ /// in the path.
+ /// Get the `export_pk` from the response of the request to [Create new export](api:POST/api/projects/{id}/exports/)
+ /// or after [listing export files](api:GET/api/projects/{id}/exports/).
+ /// + ///
+ /// + /// + /// /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ILearningResourcesClient.ExportUserProgressCsv.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ILearningResourcesClient.ExportUserProgressCsv.g.cs index b76f7baf..f68350a5 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ILearningResourcesClient.ExportUserProgressCsv.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ILearningResourcesClient.ExportUserProgressCsv.g.cs @@ -71,6 +71,33 @@ public partial interface ILearningResourcesClient /// /// /// + /// The response metadata and an unbuffered body stream. The caller must dispose Body to release the HTTP 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> ExportUserProgressCsvAsStreamAsResponseAsync( + int id, + string? columns = default, + string? ordering = default, + string? search = default, + string? status = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// ✨ Export user progress for a learning resource
+ /// <Card href="https://humansignal.com/goenterprise">
+ /// <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
+ /// <p style="margin-top: 10px; font-size: 14px;">
+ /// This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
+ /// </p>
+ /// </Card>
+ /// Export filtered course learner progress as CSV. + ///
+ /// + /// + /// + /// + /// /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// diff --git a/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.ExportCsv.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.ExportCsv.g.cs index 7b32f857..35af8d7e 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.ExportCsv.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.IProjectsClient.ExportCsv.g.cs @@ -106,6 +106,47 @@ public partial interface IProjectsClient /// /// /// + /// The response metadata and an unbuffered body stream. The caller must dispose Body to release the HTTP 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> ExportCsvAsStreamAsResponseAsync( + int id, + string? ids = default, + bool? @implicit = default, + string? lastActivityGte = default, + string? lastActivityLte = default, + string? ordering = default, + string? role = default, + string? search = default, + string? tags = default, + string? tagsOperator = default, + string? userType = default, + bool? withDeleted = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// ✨ Export project members as CSV
+ /// <Card href="https://humansignal.com/goenterprise">
+ /// <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
+ /// <p style="margin-top: 10px; font-size: 14px;">
+ /// This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
+ /// </p>
+ /// </Card>
+ /// Download every member of a project matching the supplied member-list filters as a CSV file. This endpoint is restricted to users who can manage project settings. + ///
+ /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// diff --git a/src/libs/LabelStudio/Generated/LabelStudio.LearningResourcesClient.ExportUserProgressCsv.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.LearningResourcesClient.ExportUserProgressCsv.g.cs index ed5bba79..dccbc209 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.LearningResourcesClient.ExportUserProgressCsv.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.LearningResourcesClient.ExportUserProgressCsv.g.cs @@ -393,6 +393,362 @@ partial void ProcessExportUserProgressCsvResponseContent( return new global::LabelStudio.ResponseStream(__response, __content); } + catch (global::System.OperationCanceledException) + { + throw; + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw global::LabelStudio.ApiException.Create( + statusCode: __response.StatusCode, + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + responseBody: __content, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + + } + catch + { + __response.Dispose(); + throw; + } + } + finally + { + __httpRequest?.Dispose(); + } + } + /// + /// ✨ Export user progress for a learning resource
+ /// <Card href="https://humansignal.com/goenterprise">
+ /// <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
+ /// <p style="margin-top: 10px; font-size: 14px;">
+ /// This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
+ /// </p>
+ /// </Card>
+ /// Export filtered course learner progress as CSV. + ///
+ /// + /// + /// + /// + /// + /// The response metadata and an unbuffered body stream. The caller must dispose Body to release the HTTP 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> ExportUserProgressCsvAsStreamAsResponseAsync( + int id, + string? columns = default, + string? ordering = default, + string? search = default, + string? status = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + PrepareArguments( + client: HttpClient); + PrepareExportUserProgressCsvArguments( + httpClient: HttpClient, + columns: ref columns, + id: ref id, + ordering: ref ordering, + search: ref search, + status: ref status); + + + var __authorizations = global::LabelStudio.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_ExportUserProgressCsvSecurityRequirements, + operationName: "ExportUserProgressCsvAsync"); + + using var __timeoutCancellationTokenSource = global::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::LabelStudio.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::LabelStudio.PathBuilder( + path: $"/api/learning-resources/{id}/user-progress/export/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("columns", columns) + .AddOptionalParameter("ordering", ordering) + .AddOptionalParameter("search", search) + .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; +#endif + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareExportUserProgressCsvRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + columns: columns, + id: id, + ordering: ordering, + search: search, + status: status); + + 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: "ExportUserProgressCsv", + methodName: "ExportUserProgressCsvAsync", + pathTemplate: "$\"/api/learning-resources/{id}/user-progress/export/\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseHeadersRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::LabelStudio.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ExportUserProgressCsv", + methodName: "ExportUserProgressCsvAsync", + pathTemplate: "$\"/api/learning-resources/{id}/user-progress/export/\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::LabelStudio.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ExportUserProgressCsv", + methodName: "ExportUserProgressCsvAsync", + pathTemplate: "$\"/api/learning-resources/{id}/user-progress/export/\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + try + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessExportUserProgressCsvResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ExportUserProgressCsv", + methodName: "ExportUserProgressCsvAsync", + pathTemplate: "$\"/api/learning-resources/{id}/user-progress/export/\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ExportUserProgressCsv", + methodName: "ExportUserProgressCsvAsync", + pathTemplate: "$\"/api/learning-resources/{id}/user-progress/export/\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + + try + { + __response.EnsureSuccessStatusCode(); + + var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return new global::LabelStudio.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::LabelStudio.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: new global::LabelStudio.ResponseStream(__response, __content)); + } + catch (global::System.OperationCanceledException) + { + throw; + } catch (global::System.Exception __ex) { string? __content = null; diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.ExportCsv.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.ExportCsv.g.cs index 2c270d9d..a6ac0506 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.ExportCsv.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ProjectsClient.ExportCsv.g.cs @@ -463,6 +463,397 @@ partial void ProcessExportCsvResponseContent( return new global::LabelStudio.ResponseStream(__response, __content); } + catch (global::System.OperationCanceledException) + { + throw; + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw global::LabelStudio.ApiException.Create( + statusCode: __response.StatusCode, + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + responseBody: __content, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + + } + catch + { + __response.Dispose(); + throw; + } + } + finally + { + __httpRequest?.Dispose(); + } + } + /// + /// ✨ Export project members as CSV
+ /// <Card href="https://humansignal.com/goenterprise">
+ /// <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
+ /// <p style="margin-top: 10px; font-size: 14px;">
+ /// This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
+ /// </p>
+ /// </Card>
+ /// Download every member of a project matching the supplied member-list filters as a CSV file. This endpoint is restricted to users who can manage project settings. + ///
+ /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// The response metadata and an unbuffered body stream. The caller must dispose Body to release the HTTP 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> ExportCsvAsStreamAsResponseAsync( + int id, + string? ids = default, + bool? @implicit = default, + string? lastActivityGte = default, + string? lastActivityLte = default, + string? ordering = default, + string? role = default, + string? search = default, + string? tags = default, + string? tagsOperator = default, + string? userType = default, + bool? withDeleted = default, + global::LabelStudio.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + PrepareArguments( + client: HttpClient); + PrepareExportCsvArguments( + httpClient: HttpClient, + id: ref id, + ids: ref ids, + @implicit: ref @implicit, + lastActivityGte: ref lastActivityGte, + lastActivityLte: ref lastActivityLte, + ordering: ref ordering, + role: ref role, + search: ref search, + tags: ref tags, + tagsOperator: ref tagsOperator, + userType: ref userType, + withDeleted: ref withDeleted); + + + var __authorizations = global::LabelStudio.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_ExportCsvSecurityRequirements, + operationName: "ExportCsvAsync"); + + using var __timeoutCancellationTokenSource = global::LabelStudio.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::LabelStudio.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = 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/export/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("ids", ids) + .AddOptionalParameter("implicit", @implicit?.ToString().ToLowerInvariant()) + .AddOptionalParameter("last_activity__gte", lastActivityGte) + .AddOptionalParameter("last_activity__lte", lastActivityLte) + .AddOptionalParameter("ordering", ordering) + .AddOptionalParameter("role", role) + .AddOptionalParameter("search", search) + .AddOptionalParameter("tags", tags) + .AddOptionalParameter("tags_operator", tagsOperator) + .AddOptionalParameter("user_type", userType) + .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; +#endif + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + global::LabelStudio.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareExportCsvRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id, + ids: ids, + @implicit: @implicit, + lastActivityGte: lastActivityGte, + lastActivityLte: lastActivityLte, + ordering: ordering, + role: role, + search: search, + tags: tags, + tagsOperator: tagsOperator, + userType: userType, + withDeleted: withDeleted); + + 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: "ExportCsv", + methodName: "ExportCsvAsync", + pathTemplate: "$\"/api/projects/{id}/members/export/\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseHeadersRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::LabelStudio.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ExportCsv", + methodName: "ExportCsvAsync", + pathTemplate: "$\"/api/projects/{id}/members/export/\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::LabelStudio.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::LabelStudio.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ExportCsv", + methodName: "ExportCsvAsync", + pathTemplate: "$\"/api/projects/{id}/members/export/\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::LabelStudio.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + try + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessExportCsvResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ExportCsv", + methodName: "ExportCsvAsync", + pathTemplate: "$\"/api/projects/{id}/members/export/\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::LabelStudio.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::LabelStudio.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ExportCsv", + methodName: "ExportCsvAsync", + pathTemplate: "$\"/api/projects/{id}/members/export/\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + + try + { + __response.EnsureSuccessStatusCode(); + + var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return new global::LabelStudio.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::LabelStudio.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: new global::LabelStudio.ResponseStream(__response, __content)); + } + catch (global::System.OperationCanceledException) + { + throw; + } catch (global::System.Exception __ex) { string? __content = null; diff --git a/src/libs/LabelStudio/Generated/LabelStudio.ResponseStream.g.cs b/src/libs/LabelStudio/Generated/LabelStudio.ResponseStream.g.cs index 42ddbf13..b9efa668 100644 --- a/src/libs/LabelStudio/Generated/LabelStudio.ResponseStream.g.cs +++ b/src/libs/LabelStudio/Generated/LabelStudio.ResponseStream.g.cs @@ -7,7 +7,7 @@ internal sealed class ResponseStream : global::System.IO.Stream { private readonly global::System.Net.Http.HttpResponseMessage _response; private readonly global::System.IO.Stream _stream; - private bool _disposed; + private int _disposed; public ResponseStream( global::System.Net.Http.HttpResponseMessage response, @@ -47,21 +47,51 @@ public override int WriteTimeout global::System.Threading.CancellationToken cancellationToken) => _stream.FlushAsync(cancellationToken); - public override int Read(byte[] buffer, int offset, int count) => - _stream.Read(buffer, offset, count); + public override int Read(byte[] buffer, int offset, int count) + { + try + { + return _stream.Read(buffer, offset, count); + } + catch + { + Dispose(); + throw; + } + } - public override global::System.Threading.Tasks.Task ReadAsync( + public override async global::System.Threading.Tasks.Task ReadAsync( byte[] buffer, int offset, int count, - global::System.Threading.CancellationToken cancellationToken) => - _stream.ReadAsync(buffer, offset, count, cancellationToken); + global::System.Threading.CancellationToken cancellationToken) + { + try + { + return await _stream.ReadAsync(buffer, offset, count, cancellationToken).ConfigureAwait(false); + } + catch + { + Dispose(); + throw; + } + } #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_0_OR_GREATER || NET5_0_OR_GREATER - public override global::System.Threading.Tasks.ValueTask ReadAsync( + public override async global::System.Threading.Tasks.ValueTask ReadAsync( global::System.Memory buffer, - global::System.Threading.CancellationToken cancellationToken = default) => - _stream.ReadAsync(buffer, cancellationToken); + global::System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await _stream.ReadAsync(buffer, cancellationToken).ConfigureAwait(false); + } + catch + { + Dispose(); + throw; + } + } #endif public override long Seek(long offset, global::System.IO.SeekOrigin origin) => @@ -89,10 +119,9 @@ public override void Write(byte[] buffer, int offset, int count) => protected override void Dispose(bool disposing) { - if (!_disposed && disposing) + if (disposing && global::System.Threading.Interlocked.Exchange(ref _disposed, 1) == 0) { - _disposed = true; - _stream.Dispose(); + // The response content owns the underlying stream; disposing both would close it twice. _response.Dispose(); } @@ -100,17 +129,10 @@ protected override void Dispose(bool disposing) } #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_0_OR_GREATER || NET5_0_OR_GREATER - public override async global::System.Threading.Tasks.ValueTask DisposeAsync() + public override global::System.Threading.Tasks.ValueTask DisposeAsync() { - if (_disposed) - { - return; - } - - _disposed = true; - await _stream.DisposeAsync().ConfigureAwait(false); - _response.Dispose(); - await base.DisposeAsync().ConfigureAwait(false); + Dispose(); + return default; } #endif }