From 3e791eaae41d96ee503d95cab5a91c751629c252 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 26 Oct 2026 03:41:00 +0000 Subject: [PATCH] feat: Updated OpenAPI spec --- ...chedVideoMp4StaticMp4MachineIPFileGet.g.cs | 14 + ...tCachedVideoStaticHlsMachineIPFileGet.g.cs | 15 + ...rocessImageFacesTrinityPreprocessPost.g.cs | 49 + .../Simli/Generated/Simli.ResponseStream.g.cs | 66 +- ...chedVideoMp4StaticMp4MachineIPFileGet.g.cs | 400 ++++++ ...tCachedVideoStaticHlsMachineIPFileGet.g.cs | 401 ++++++ ...rocessImageFacesTrinityPreprocessPost.g.cs | 1114 +++++++++++++++-- 7 files changed, 1906 insertions(+), 153 deletions(-) diff --git a/src/libs/Simli/Generated/Simli.ISimliClient.GetCachedVideoMp4StaticMp4MachineIPFileGet.g.cs b/src/libs/Simli/Generated/Simli.ISimliClient.GetCachedVideoMp4StaticMp4MachineIPFileGet.g.cs index b90f142..99856e6 100644 --- a/src/libs/Simli/Generated/Simli.ISimliClient.GetCachedVideoMp4StaticMp4MachineIPFileGet.g.cs +++ b/src/libs/Simli/Generated/Simli.ISimliClient.GetCachedVideoMp4StaticMp4MachineIPFileGet.g.cs @@ -35,6 +35,20 @@ public partial interface ISimliClient /// /// /// + /// 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> GetCachedVideoMp4StaticMp4MachineIPFileGetAsStreamAsResponseAsync( + string destination, + string file, + global::Simli.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Get MP4 of Generated Video + /// + /// + /// /// 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/Simli/Generated/Simli.ISimliClient.GetCachedVideoStaticHlsMachineIPFileGet.g.cs b/src/libs/Simli/Generated/Simli.ISimliClient.GetCachedVideoStaticHlsMachineIPFileGet.g.cs index 2f87666..1d62fa1 100644 --- a/src/libs/Simli/Generated/Simli.ISimliClient.GetCachedVideoStaticHlsMachineIPFileGet.g.cs +++ b/src/libs/Simli/Generated/Simli.ISimliClient.GetCachedVideoStaticHlsMachineIPFileGet.g.cs @@ -38,6 +38,21 @@ public partial interface ISimliClient /// /// /// + /// 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> GetCachedVideoStaticHlsMachineIPFileGetAsStreamAsResponseAsync( + string destination, + string file, + global::Simli.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Get HLS Segment
+ /// Get HLS Stream of Generated Video + ///
+ /// + /// /// 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/Simli/Generated/Simli.ISimliClient.PreprocessImageFacesTrinityPreprocessPost.g.cs b/src/libs/Simli/Generated/Simli.ISimliClient.PreprocessImageFacesTrinityPreprocessPost.g.cs index 22cc5be..5ea807a 100644 --- a/src/libs/Simli/Generated/Simli.ISimliClient.PreprocessImageFacesTrinityPreprocessPost.g.cs +++ b/src/libs/Simli/Generated/Simli.ISimliClient.PreprocessImageFacesTrinityPreprocessPost.g.cs @@ -57,6 +57,28 @@ public partial interface ISimliClient /// 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 + /// + global::System.Threading.Tasks.Task> PreprocessImageFacesTrinityPreprocessPostAsStreamAsResponseAsync( + + global::Simli.BodyPreprocessImageFacesTrinityPreprocessPost request, + global::Simli.TrinityVersion? gsVersion = default, + bool? retry = default, + global::Simli.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Preprocess Trinity Face Image
+ /// Reframes a portrait to the framing its generation expects, and returns the reframed PNG. GSA_1.0: the head centred with equal padding above and below, squared to the camera, on a simplified version of the image's own background. GSA_2.0: the person waist-up, with the torso and both hands, on the image's own background. Either way, the image needs someone facing the camera. + ///
+ /// + /// Default Value: GSA_1.0 + /// + /// + /// Default Value: false + /// + /// /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// @@ -162,6 +184,33 @@ public partial interface ISimliClient /// /// JPEG, PNG or WEBP, under 5MB, at least 512x512. It must contain a person facing the camera whose head is at least 15% of the image height - a head smaller than that carries too few pixels to keep the likeness, and is rejected. Where several people are present, the largest camera-facing head is treated as the subject. /// + /// 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> PreprocessImageFacesTrinityPreprocessPostAsStreamAsResponseAsync( + global::System.IO.Stream image, + string imagename, + global::Simli.TrinityVersion? gsVersion = default, + bool? retry = default, + global::Simli.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Preprocess Trinity Face Image
+ /// Reframes a portrait to the framing its generation expects, and returns the reframed PNG. GSA_1.0: the head centred with equal padding above and below, squared to the camera, on a simplified version of the image's own background. GSA_2.0: the person waist-up, with the torso and both hands, on the image's own background. Either way, the image needs someone facing the camera. + ///
+ /// + /// Default Value: GSA_1.0 + /// + /// + /// Default Value: false + /// + /// + /// JPEG, PNG or WEBP, under 5MB, at least 512x512. It must contain a person facing the camera whose head is at least 15% of the image height - a head smaller than that carries too few pixels to keep the likeness, and is rejected. Where several people are present, the largest camera-facing head is treated as the subject. + /// + /// + /// JPEG, PNG or WEBP, under 5MB, at least 512x512. It must contain a person facing the camera whose head is at least 15% of the image height - a head smaller than that carries too few pixels to keep the likeness, and is rejected. Where several people are present, the largest camera-facing head is treated as the subject. + /// /// 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/Simli/Generated/Simli.ResponseStream.g.cs b/src/libs/Simli/Generated/Simli.ResponseStream.g.cs index 53fae2e..792e272 100644 --- a/src/libs/Simli/Generated/Simli.ResponseStream.g.cs +++ b/src/libs/Simli/Generated/Simli.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 } diff --git a/src/libs/Simli/Generated/Simli.SimliClient.GetCachedVideoMp4StaticMp4MachineIPFileGet.g.cs b/src/libs/Simli/Generated/Simli.SimliClient.GetCachedVideoMp4StaticMp4MachineIPFileGet.g.cs index 54411a0..6e3feea 100644 --- a/src/libs/Simli/Generated/Simli.SimliClient.GetCachedVideoMp4StaticMp4MachineIPFileGet.g.cs +++ b/src/libs/Simli/Generated/Simli.SimliClient.GetCachedVideoMp4StaticMp4MachineIPFileGet.g.cs @@ -415,6 +415,406 @@ partial void ProcessGetCachedVideoMp4StaticMp4MachineIPFileGetResponseContent( return new global::Simli.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::Simli.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(); + } + } + /// + /// Get MP4 of Generated Video + /// + /// + /// + /// 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> GetCachedVideoMp4StaticMp4MachineIPFileGetAsStreamAsResponseAsync( + string destination, + string file, + global::Simli.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + PrepareArguments( + client: HttpClient); + PrepareGetCachedVideoMp4StaticMp4MachineIPFileGetArguments( + httpClient: HttpClient, + destination: ref destination, + file: ref file); + + + var __authorizations = global::Simli.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_GetCachedVideoMp4StaticMp4MachineIPFileGetSecurityRequirements, + operationName: "GetCachedVideoMp4StaticMp4MachineIPFileGetAsync"); + + using var __timeoutCancellationTokenSource = global::Simli.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Simli.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Simli.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Simli.PathBuilder( + path: $"/static/mp4/{destination}/{file}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Simli.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::Simli.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetCachedVideoMp4StaticMp4MachineIPFileGetRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + destination: destination, + file: file); + + 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::Simli.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Simli.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetCachedVideoMp4StaticMp4MachineIPFileGet", + methodName: "GetCachedVideoMp4StaticMp4MachineIPFileGetAsync", + pathTemplate: "$\"/static/mp4/{destination}/{file}\"", + 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::Simli.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Simli.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Simli.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetCachedVideoMp4StaticMp4MachineIPFileGet", + methodName: "GetCachedVideoMp4StaticMp4MachineIPFileGetAsync", + pathTemplate: "$\"/static/mp4/{destination}/{file}\"", + 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::Simli.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Simli.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Simli.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Simli.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Simli.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetCachedVideoMp4StaticMp4MachineIPFileGet", + methodName: "GetCachedVideoMp4StaticMp4MachineIPFileGetAsync", + pathTemplate: "$\"/static/mp4/{destination}/{file}\"", + 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::Simli.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); + ProcessGetCachedVideoMp4StaticMp4MachineIPFileGetResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Simli.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Simli.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetCachedVideoMp4StaticMp4MachineIPFileGet", + methodName: "GetCachedVideoMp4StaticMp4MachineIPFileGetAsync", + pathTemplate: "$\"/static/mp4/{destination}/{file}\"", + 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::Simli.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Simli.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetCachedVideoMp4StaticMp4MachineIPFileGet", + methodName: "GetCachedVideoMp4StaticMp4MachineIPFileGetAsync", + pathTemplate: "$\"/static/mp4/{destination}/{file}\"", + 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); + } + // + 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 global::Simli.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + responseBody: __content_404, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Validation Error + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Simli.HTTPValidationError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Simli.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_422 = global::Simli.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + + throw global::Simli.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + responseBody: __content_422, + responseObject: __value_422, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + + try + { + __response.EnsureSuccessStatusCode(); + + var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return new global::Simli.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Simli.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: new global::Simli.ResponseStream(__response, __content)); + } + catch (global::System.OperationCanceledException) + { + throw; + } catch (global::System.Exception __ex) { string? __content = null; diff --git a/src/libs/Simli/Generated/Simli.SimliClient.GetCachedVideoStaticHlsMachineIPFileGet.g.cs b/src/libs/Simli/Generated/Simli.SimliClient.GetCachedVideoStaticHlsMachineIPFileGet.g.cs index 1a413f6..d3d2590 100644 --- a/src/libs/Simli/Generated/Simli.SimliClient.GetCachedVideoStaticHlsMachineIPFileGet.g.cs +++ b/src/libs/Simli/Generated/Simli.SimliClient.GetCachedVideoStaticHlsMachineIPFileGet.g.cs @@ -417,6 +417,407 @@ partial void ProcessGetCachedVideoStaticHlsMachineIPFileGetResponseContent( return new global::Simli.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::Simli.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(); + } + } + /// + /// Get HLS Segment
+ /// Get HLS Stream of Generated Video + ///
+ /// + /// + /// 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> GetCachedVideoStaticHlsMachineIPFileGetAsStreamAsResponseAsync( + string destination, + string file, + global::Simli.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + PrepareArguments( + client: HttpClient); + PrepareGetCachedVideoStaticHlsMachineIPFileGetArguments( + httpClient: HttpClient, + destination: ref destination, + file: ref file); + + + var __authorizations = global::Simli.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_GetCachedVideoStaticHlsMachineIPFileGetSecurityRequirements, + operationName: "GetCachedVideoStaticHlsMachineIPFileGetAsync"); + + using var __timeoutCancellationTokenSource = global::Simli.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Simli.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Simli.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Simli.PathBuilder( + path: $"/static/hls/{destination}/{file}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Simli.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::Simli.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetCachedVideoStaticHlsMachineIPFileGetRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + destination: destination, + file: file); + + 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::Simli.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Simli.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetCachedVideoStaticHlsMachineIPFileGet", + methodName: "GetCachedVideoStaticHlsMachineIPFileGetAsync", + pathTemplate: "$\"/static/hls/{destination}/{file}\"", + 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::Simli.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Simli.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Simli.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetCachedVideoStaticHlsMachineIPFileGet", + methodName: "GetCachedVideoStaticHlsMachineIPFileGetAsync", + pathTemplate: "$\"/static/hls/{destination}/{file}\"", + 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::Simli.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Simli.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Simli.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Simli.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Simli.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetCachedVideoStaticHlsMachineIPFileGet", + methodName: "GetCachedVideoStaticHlsMachineIPFileGetAsync", + pathTemplate: "$\"/static/hls/{destination}/{file}\"", + 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::Simli.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); + ProcessGetCachedVideoStaticHlsMachineIPFileGetResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Simli.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Simli.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetCachedVideoStaticHlsMachineIPFileGet", + methodName: "GetCachedVideoStaticHlsMachineIPFileGetAsync", + pathTemplate: "$\"/static/hls/{destination}/{file}\"", + 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::Simli.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Simli.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetCachedVideoStaticHlsMachineIPFileGet", + methodName: "GetCachedVideoStaticHlsMachineIPFileGetAsync", + pathTemplate: "$\"/static/hls/{destination}/{file}\"", + 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); + } + // + 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 global::Simli.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + responseBody: __content_404, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Validation Error + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Simli.HTTPValidationError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Simli.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_422 = global::Simli.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + + throw global::Simli.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + responseBody: __content_422, + responseObject: __value_422, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + + try + { + __response.EnsureSuccessStatusCode(); + + var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return new global::Simli.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Simli.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: new global::Simli.ResponseStream(__response, __content)); + } + catch (global::System.OperationCanceledException) + { + throw; + } catch (global::System.Exception __ex) { string? __content = null; diff --git a/src/libs/Simli/Generated/Simli.SimliClient.PreprocessImageFacesTrinityPreprocessPost.g.cs b/src/libs/Simli/Generated/Simli.SimliClient.PreprocessImageFacesTrinityPreprocessPost.g.cs index 55e4c80..50b4e62 100644 --- a/src/libs/Simli/Generated/Simli.SimliClient.PreprocessImageFacesTrinityPreprocessPost.g.cs +++ b/src/libs/Simli/Generated/Simli.SimliClient.PreprocessImageFacesTrinityPreprocessPost.g.cs @@ -448,6 +448,10 @@ request.Imagename is null return new global::Simli.ResponseStream(__response, __content); } + catch (global::System.OperationCanceledException) + { + throw; + } catch (global::System.Exception __ex) { string? __content = null; @@ -497,10 +501,11 @@ request.Imagename is null /// 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> PreprocessImageFacesTrinityPreprocessPostAsResponseAsync( + public async global::System.Threading.Tasks.Task> PreprocessImageFacesTrinityPreprocessPostAsStreamAsResponseAsync( global::Simli.BodyPreprocessImageFacesTrinityPreprocessPost request, global::Simli.TrinityVersion? gsVersion = default, @@ -669,7 +674,7 @@ request.Imagename is null { __response = await HttpClient.SendAsync( request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } catch (global::System.Net.Http.HttpRequestException __exception) @@ -758,7 +763,7 @@ request.Imagename is null throw new global::System.InvalidOperationException("No response received."); } - using (__response) + try { ProcessResponse( @@ -844,87 +849,58 @@ request.Imagename is null h => h.Value)); } - if (__effectiveReadResponseAsString) + try { - var __content = await __response.Content.ReadAsByteArrayAsync( + __response.EnsureSuccessStatusCode(); + + var __content = await __response.Content.ReadAsStreamAsync( #if NET5_0_OR_GREATER __effectiveCancellationToken #endif ).ConfigureAwait(false); - ProcessPreprocessImageFacesTrinityPreprocessPostResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try - { - __response.EnsureSuccessStatusCode(); - - return new global::Simli.AutoSDKHttpResponse( - statusCode: __response.StatusCode, - headers: global::Simli.AutoSDKHttpResponse.CreateHeaders(__response), - requestUri: __response.RequestMessage?.RequestUri, - body: __content); - } - catch (global::System.Exception __ex) - { - throw global::Simli.ApiException.Create( - statusCode: __response.StatusCode, - message: __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - responseBody: null, - responseHeaders: global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value)); - } + return new global::Simli.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Simli.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: new global::Simli.ResponseStream(__response, __content)); } - else + catch (global::System.OperationCanceledException) + { + throw; + } + catch (global::System.Exception __ex) { + string? __content = null; try { - __response.EnsureSuccessStatusCode(); - var __content = await __response.Content.ReadAsByteArrayAsync( + __content = await __response.Content.ReadAsStringAsync( #if NET5_0_OR_GREATER __effectiveCancellationToken #endif ).ConfigureAwait(false); - - return new global::Simli.AutoSDKHttpResponse( - statusCode: __response.StatusCode, - headers: global::Simli.AutoSDKHttpResponse.CreateHeaders(__response), - requestUri: __response.RequestMessage?.RequestUri, - body: __content); } - catch (global::System.Exception __ex) + catch (global::System.Exception) { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( - #if NET5_0_OR_GREATER - __effectiveCancellationToken - #endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } - - throw global::Simli.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)); } + + throw global::Simli.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 { @@ -941,71 +917,20 @@ request.Imagename is null /// /// Default Value: false /// - /// - /// JPEG, PNG or WEBP, under 5MB, at least 512x512. It must contain a person facing the camera whose head is at least 15% of the image height - a head smaller than that carries too few pixels to keep the likeness, and is rejected. Where several people are present, the largest camera-facing head is treated as the subject. - /// - /// - /// JPEG, PNG or WEBP, under 5MB, at least 512x512. It must contain a person facing the camera whose head is at least 15% of the image height - a head smaller than that carries too few pixels to keep the likeness, and is rejected. Where several people are present, the largest camera-facing head is treated as the subject. - /// - /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. - /// The token to cancel the operation with - /// - public async global::System.Threading.Tasks.Task PreprocessImageFacesTrinityPreprocessPostAsync( - byte[] image, - string imagename, - global::Simli.TrinityVersion? gsVersion = default, - bool? retry = default, - global::Simli.AutoSDKRequestOptions? requestOptions = default, - global::System.Threading.CancellationToken cancellationToken = default) - { - var __request = new global::Simli.BodyPreprocessImageFacesTrinityPreprocessPost - { - Image = image, - Imagename = imagename, - }; - - return await PreprocessImageFacesTrinityPreprocessPostAsync( - gsVersion: gsVersion, - retry: retry, - request: __request, - requestOptions: requestOptions, - cancellationToken: cancellationToken).ConfigureAwait(false); - } - - /// - /// Preprocess Trinity Face Image
- /// Reframes a portrait to the framing its generation expects, and returns the reframed PNG. GSA_1.0: the head centred with equal padding above and below, squared to the camera, on a simplified version of the image's own background. GSA_2.0: the person waist-up, with the torso and both hands, on the image's own background. Either way, the image needs someone facing the camera. - ///
- /// - /// Default Value: GSA_1.0 - /// - /// - /// Default Value: false - /// - /// - /// JPEG, PNG or WEBP, under 5MB, at least 512x512. It must contain a person facing the camera whose head is at least 15% of the image height - a head smaller than that carries too few pixels to keep the likeness, and is rejected. Where several people are present, the largest camera-facing head is treated as the subject. - /// - /// - /// JPEG, PNG or WEBP, under 5MB, at least 512x512. It must contain a person facing the camera whose head is at least 15% of the image height - a head smaller than that carries too few pixels to keep the likeness, and is rejected. Where several people are present, the largest camera-facing head is treated as the subject. - /// + /// /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// - public async global::System.Threading.Tasks.Task PreprocessImageFacesTrinityPreprocessPostAsync( - global::System.IO.Stream image, - string imagename, + public async global::System.Threading.Tasks.Task> PreprocessImageFacesTrinityPreprocessPostAsResponseAsync( + + global::Simli.BodyPreprocessImageFacesTrinityPreprocessPost request, global::Simli.TrinityVersion? gsVersion = default, bool? retry = default, global::Simli.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { + request = request ?? throw new global::System.ArgumentNullException(nameof(request)); - image = image ?? throw new global::System.ArgumentNullException(nameof(image)); - var request = new global::Simli.BodyPreprocessImageFacesTrinityPreprocessPost - { - Image = global::System.Array.Empty(), - Imagename = imagename, - }; PrepareArguments( client: HttpClient); PreparePreprocessImageFacesTrinityPreprocessPostArguments( @@ -1075,7 +1000,7 @@ request.Imagename is null } var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); - var __contentImage = new global::System.Net.Http.StreamContent(image); + var __contentImage = new global::System.Net.Http.ByteArrayContent(request.Image ?? global::System.Array.Empty()); __contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( request.Imagename is null ? "application/octet-stream" @@ -1357,7 +1282,11 @@ request.Imagename is null { __response.EnsureSuccessStatusCode(); - return __content; + return new global::Simli.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Simli.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __content); } catch (global::System.Exception __ex) { @@ -1383,7 +1312,11 @@ request.Imagename is null #endif ).ConfigureAwait(false); - return __content; + return new global::Simli.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Simli.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __content); } catch (global::System.Exception __ex) { @@ -1419,6 +1352,47 @@ request.Imagename is null __httpRequest?.Dispose(); } } + /// + /// Preprocess Trinity Face Image
+ /// Reframes a portrait to the framing its generation expects, and returns the reframed PNG. GSA_1.0: the head centred with equal padding above and below, squared to the camera, on a simplified version of the image's own background. GSA_2.0: the person waist-up, with the torso and both hands, on the image's own background. Either way, the image needs someone facing the camera. + ///
+ /// + /// Default Value: GSA_1.0 + /// + /// + /// Default Value: false + /// + /// + /// JPEG, PNG or WEBP, under 5MB, at least 512x512. It must contain a person facing the camera whose head is at least 15% of the image height - a head smaller than that carries too few pixels to keep the likeness, and is rejected. Where several people are present, the largest camera-facing head is treated as the subject. + /// + /// + /// JPEG, PNG or WEBP, under 5MB, at least 512x512. It must contain a person facing the camera whose head is at least 15% of the image height - a head smaller than that carries too few pixels to keep the likeness, and is rejected. Where several people are present, the largest camera-facing head is treated as the subject. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task PreprocessImageFacesTrinityPreprocessPostAsync( + byte[] image, + string imagename, + global::Simli.TrinityVersion? gsVersion = default, + bool? retry = default, + global::Simli.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __request = new global::Simli.BodyPreprocessImageFacesTrinityPreprocessPost + { + Image = image, + Imagename = imagename, + }; + + return await PreprocessImageFacesTrinityPreprocessPostAsync( + gsVersion: gsVersion, + retry: retry, + request: __request, + requestOptions: requestOptions, + cancellationToken: cancellationToken).ConfigureAwait(false); + } + /// /// Preprocess Trinity Face Image
/// Reframes a portrait to the framing its generation expects, and returns the reframed PNG. GSA_1.0: the head centred with equal padding above and below, squared to the camera, on a simplified version of the image's own background. GSA_2.0: the person waist-up, with the torso and both hands, on the image's own background. Either way, the image needs someone facing the camera. @@ -1438,7 +1412,7 @@ request.Imagename is null /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// - public async global::System.Threading.Tasks.Task PreprocessImageFacesTrinityPreprocessPostAsStreamAsync( + public async global::System.Threading.Tasks.Task PreprocessImageFacesTrinityPreprocessPostAsync( global::System.IO.Stream image, string imagename, global::Simli.TrinityVersion? gsVersion = default, @@ -1612,7 +1586,7 @@ request.Imagename is null { __response = await HttpClient.SendAsync( request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseHeadersRead, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } catch (global::System.Net.Http.HttpRequestException __exception) @@ -1701,7 +1675,7 @@ request.Imagename is null throw new global::System.InvalidOperationException("No response received."); } - try + using (__response) { ProcessResponse( @@ -1787,17 +1761,895 @@ request.Imagename is null h => h.Value)); } - try + if (__effectiveReadResponseAsString) { - __response.EnsureSuccessStatusCode(); - - var __content = await __response.Content.ReadAsStreamAsync( + var __content = await __response.Content.ReadAsByteArrayAsync( #if NET5_0_OR_GREATER __effectiveCancellationToken #endif ).ConfigureAwait(false); - return new global::Simli.ResponseStream(__response, __content); + ProcessPreprocessImageFacesTrinityPreprocessPostResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return __content; + } + catch (global::System.Exception __ex) + { + throw global::Simli.ApiException.Create( + statusCode: __response.StatusCode, + message: __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + responseBody: null, + 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 global::Simli.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)); + } + } + + } + } + finally + { + __httpRequest?.Dispose(); + } + } + /// + /// Preprocess Trinity Face Image
+ /// Reframes a portrait to the framing its generation expects, and returns the reframed PNG. GSA_1.0: the head centred with equal padding above and below, squared to the camera, on a simplified version of the image's own background. GSA_2.0: the person waist-up, with the torso and both hands, on the image's own background. Either way, the image needs someone facing the camera. + ///
+ /// + /// Default Value: GSA_1.0 + /// + /// + /// Default Value: false + /// + /// + /// JPEG, PNG or WEBP, under 5MB, at least 512x512. It must contain a person facing the camera whose head is at least 15% of the image height - a head smaller than that carries too few pixels to keep the likeness, and is rejected. Where several people are present, the largest camera-facing head is treated as the subject. + /// + /// + /// JPEG, PNG or WEBP, under 5MB, at least 512x512. It must contain a person facing the camera whose head is at least 15% of the image height - a head smaller than that carries too few pixels to keep the likeness, and is rejected. Where several people are present, the largest camera-facing head is treated as the subject. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task PreprocessImageFacesTrinityPreprocessPostAsStreamAsync( + global::System.IO.Stream image, + string imagename, + global::Simli.TrinityVersion? gsVersion = default, + bool? retry = default, + global::Simli.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + + image = image ?? throw new global::System.ArgumentNullException(nameof(image)); + var request = new global::Simli.BodyPreprocessImageFacesTrinityPreprocessPost + { + Image = global::System.Array.Empty(), + Imagename = imagename, + }; + PrepareArguments( + client: HttpClient); + PreparePreprocessImageFacesTrinityPreprocessPostArguments( + httpClient: HttpClient, + gsVersion: ref gsVersion, + retry: ref retry, + request: request); + + + var __authorizations = global::Simli.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_PreprocessImageFacesTrinityPreprocessPostSecurityRequirements, + operationName: "PreprocessImageFacesTrinityPreprocessPostAsync"); + + using var __timeoutCancellationTokenSource = global::Simli.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Simli.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Simli.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Simli.PathBuilder( + path: "/faces/trinity/preprocess", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("gsVersion", gsVersion?.ToString()) + .AddOptionalParameter("retry", retry?.ToString().ToLowerInvariant()) + ; + var __path = __pathBuilder.ToString(); + __path = global::Simli.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; +#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); + } + } + + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + var __contentImage = new global::System.Net.Http.StreamContent(image); + __contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + request.Imagename is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(request.Imagename) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentImage, + name: "\"image\"", + fileName: request.Imagename != null ? $"\"{request.Imagename}\"" : string.Empty); + if (__contentImage.Headers.ContentDisposition != null) + { + __contentImage.Headers.ContentDisposition.FileNameStar = null; + } + + __httpRequest.Content = __httpRequestContent; + + global::Simli.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PreparePreprocessImageFacesTrinityPreprocessPostRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + gsVersion: gsVersion, + retry: retry, + request: request); + + 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::Simli.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Simli.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PreprocessImageFacesTrinityPreprocessPost", + methodName: "PreprocessImageFacesTrinityPreprocessPostAsync", + pathTemplate: "\"/faces/trinity/preprocess\"", + httpMethod: "POST", + 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::Simli.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Simli.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Simli.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PreprocessImageFacesTrinityPreprocessPost", + methodName: "PreprocessImageFacesTrinityPreprocessPostAsync", + pathTemplate: "\"/faces/trinity/preprocess\"", + httpMethod: "POST", + 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::Simli.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Simli.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Simli.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Simli.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Simli.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PreprocessImageFacesTrinityPreprocessPost", + methodName: "PreprocessImageFacesTrinityPreprocessPostAsync", + pathTemplate: "\"/faces/trinity/preprocess\"", + httpMethod: "POST", + 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::Simli.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); + ProcessPreprocessImageFacesTrinityPreprocessPostResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Simli.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Simli.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PreprocessImageFacesTrinityPreprocessPost", + methodName: "PreprocessImageFacesTrinityPreprocessPostAsync", + pathTemplate: "\"/faces/trinity/preprocess\"", + httpMethod: "POST", + 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::Simli.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Simli.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PreprocessImageFacesTrinityPreprocessPost", + methodName: "PreprocessImageFacesTrinityPreprocessPostAsync", + pathTemplate: "\"/faces/trinity/preprocess\"", + httpMethod: "POST", + 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); + } + // + 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 global::Simli.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + responseBody: __content_403, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + + try + { + __response.EnsureSuccessStatusCode(); + + var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return new global::Simli.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::Simli.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(); + } + } + /// + /// Preprocess Trinity Face Image
+ /// Reframes a portrait to the framing its generation expects, and returns the reframed PNG. GSA_1.0: the head centred with equal padding above and below, squared to the camera, on a simplified version of the image's own background. GSA_2.0: the person waist-up, with the torso and both hands, on the image's own background. Either way, the image needs someone facing the camera. + ///
+ /// + /// Default Value: GSA_1.0 + /// + /// + /// Default Value: false + /// + /// + /// JPEG, PNG or WEBP, under 5MB, at least 512x512. It must contain a person facing the camera whose head is at least 15% of the image height - a head smaller than that carries too few pixels to keep the likeness, and is rejected. Where several people are present, the largest camera-facing head is treated as the subject. + /// + /// + /// JPEG, PNG or WEBP, under 5MB, at least 512x512. It must contain a person facing the camera whose head is at least 15% of the image height - a head smaller than that carries too few pixels to keep the likeness, and is rejected. Where several people are present, the largest camera-facing head is treated as the subject. + /// + /// 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> PreprocessImageFacesTrinityPreprocessPostAsStreamAsResponseAsync( + global::System.IO.Stream image, + string imagename, + global::Simli.TrinityVersion? gsVersion = default, + bool? retry = default, + global::Simli.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + + image = image ?? throw new global::System.ArgumentNullException(nameof(image)); + var request = new global::Simli.BodyPreprocessImageFacesTrinityPreprocessPost + { + Image = global::System.Array.Empty(), + Imagename = imagename, + }; + PrepareArguments( + client: HttpClient); + PreparePreprocessImageFacesTrinityPreprocessPostArguments( + httpClient: HttpClient, + gsVersion: ref gsVersion, + retry: ref retry, + request: request); + + + var __authorizations = global::Simli.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_PreprocessImageFacesTrinityPreprocessPostSecurityRequirements, + operationName: "PreprocessImageFacesTrinityPreprocessPostAsync"); + + using var __timeoutCancellationTokenSource = global::Simli.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Simli.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Simli.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Simli.PathBuilder( + path: "/faces/trinity/preprocess", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("gsVersion", gsVersion?.ToString()) + .AddOptionalParameter("retry", retry?.ToString().ToLowerInvariant()) + ; + var __path = __pathBuilder.ToString(); + __path = global::Simli.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; +#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); + } + } + + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + var __contentImage = new global::System.Net.Http.StreamContent(image); + __contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + request.Imagename is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(request.Imagename) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentImage, + name: "\"image\"", + fileName: request.Imagename != null ? $"\"{request.Imagename}\"" : string.Empty); + if (__contentImage.Headers.ContentDisposition != null) + { + __contentImage.Headers.ContentDisposition.FileNameStar = null; + } + + __httpRequest.Content = __httpRequestContent; + + global::Simli.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PreparePreprocessImageFacesTrinityPreprocessPostRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + gsVersion: gsVersion, + retry: retry, + request: request); + + 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::Simli.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Simli.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PreprocessImageFacesTrinityPreprocessPost", + methodName: "PreprocessImageFacesTrinityPreprocessPostAsync", + pathTemplate: "\"/faces/trinity/preprocess\"", + httpMethod: "POST", + 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::Simli.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Simli.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Simli.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PreprocessImageFacesTrinityPreprocessPost", + methodName: "PreprocessImageFacesTrinityPreprocessPostAsync", + pathTemplate: "\"/faces/trinity/preprocess\"", + httpMethod: "POST", + 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::Simli.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Simli.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Simli.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Simli.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Simli.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PreprocessImageFacesTrinityPreprocessPost", + methodName: "PreprocessImageFacesTrinityPreprocessPostAsync", + pathTemplate: "\"/faces/trinity/preprocess\"", + httpMethod: "POST", + 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::Simli.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); + ProcessPreprocessImageFacesTrinityPreprocessPostResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Simli.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Simli.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PreprocessImageFacesTrinityPreprocessPost", + methodName: "PreprocessImageFacesTrinityPreprocessPostAsync", + pathTemplate: "\"/faces/trinity/preprocess\"", + httpMethod: "POST", + 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::Simli.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Simli.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PreprocessImageFacesTrinityPreprocessPost", + methodName: "PreprocessImageFacesTrinityPreprocessPostAsync", + pathTemplate: "\"/faces/trinity/preprocess\"", + httpMethod: "POST", + 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); + } + // + 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 global::Simli.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + responseBody: __content_403, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + + try + { + __response.EnsureSuccessStatusCode(); + + var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return new global::Simli.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Simli.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: new global::Simli.ResponseStream(__response, __content)); + } + catch (global::System.OperationCanceledException) + { + throw; } catch (global::System.Exception __ex) {