diff --git a/src/libs/Simli/Generated/Simli.ISimliClient.GetCachedVideoMp4StaticMp4MachineIPFileGet.g.cs b/src/libs/Simli/Generated/Simli.ISimliClient.GetCachedVideoMp4StaticMp4MachineIPFileGet.g.cs index d4b0caa..b90f142 100644 --- a/src/libs/Simli/Generated/Simli.ISimliClient.GetCachedVideoMp4StaticMp4MachineIPFileGet.g.cs +++ b/src/libs/Simli/Generated/Simli.ISimliClient.GetCachedVideoMp4StaticMp4MachineIPFileGet.g.cs @@ -12,7 +12,7 @@ public partial interface ISimliClient /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// - global::System.Threading.Tasks.Task GetCachedVideoMp4StaticMp4MachineIPFileGetAsync( + global::System.Threading.Tasks.Task GetCachedVideoMp4StaticMp4MachineIPFileGetAsync( string destination, string file, global::Simli.AutoSDKRequestOptions? requestOptions = default, @@ -25,7 +25,20 @@ public partial interface ISimliClient /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// - global::System.Threading.Tasks.Task> GetCachedVideoMp4StaticMp4MachineIPFileGetAsResponseAsync( + global::System.Threading.Tasks.Task GetCachedVideoMp4StaticMp4MachineIPFileGetAsStreamAsync( + 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 + /// + global::System.Threading.Tasks.Task> GetCachedVideoMp4StaticMp4MachineIPFileGetAsResponseAsync( string destination, string file, global::Simli.AutoSDKRequestOptions? requestOptions = default, diff --git a/src/libs/Simli/Generated/Simli.ISimliClient.GetCachedVideoStaticHlsMachineIPFileGet.g.cs b/src/libs/Simli/Generated/Simli.ISimliClient.GetCachedVideoStaticHlsMachineIPFileGet.g.cs index 979f604..2f87666 100644 --- a/src/libs/Simli/Generated/Simli.ISimliClient.GetCachedVideoStaticHlsMachineIPFileGet.g.cs +++ b/src/libs/Simli/Generated/Simli.ISimliClient.GetCachedVideoStaticHlsMachineIPFileGet.g.cs @@ -13,7 +13,7 @@ public partial interface ISimliClient /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// - global::System.Threading.Tasks.Task GetCachedVideoStaticHlsMachineIPFileGetAsync( + global::System.Threading.Tasks.Task GetCachedVideoStaticHlsMachineIPFileGetAsync( string destination, string file, global::Simli.AutoSDKRequestOptions? requestOptions = default, @@ -27,7 +27,21 @@ public partial interface ISimliClient /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// - global::System.Threading.Tasks.Task> GetCachedVideoStaticHlsMachineIPFileGetAsResponseAsync( + global::System.Threading.Tasks.Task GetCachedVideoStaticHlsMachineIPFileGetAsStreamAsync( + 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 + /// + global::System.Threading.Tasks.Task> GetCachedVideoStaticHlsMachineIPFileGetAsResponseAsync( string destination, string file, global::Simli.AutoSDKRequestOptions? requestOptions = default, diff --git a/src/libs/Simli/Generated/Simli.ResponseStream.g.cs b/src/libs/Simli/Generated/Simli.ResponseStream.g.cs new file mode 100644 index 0000000..53fae2e --- /dev/null +++ b/src/libs/Simli/Generated/Simli.ResponseStream.g.cs @@ -0,0 +1,117 @@ + +#nullable enable + +namespace Simli +{ + 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; + + public ResponseStream( + global::System.Net.Http.HttpResponseMessage response, + global::System.IO.Stream stream) + { + _response = response ?? throw new global::System.ArgumentNullException(nameof(response)); + _stream = stream ?? throw new global::System.ArgumentNullException(nameof(stream)); + } + + public override bool CanRead => _stream.CanRead; + public override bool CanSeek => _stream.CanSeek; + public override bool CanWrite => _stream.CanWrite; + public override bool CanTimeout => _stream.CanTimeout; + public override long Length => _stream.Length; + + public override long Position + { + get => _stream.Position; + set => _stream.Position = value; + } + + public override int ReadTimeout + { + get => _stream.ReadTimeout; + set => _stream.ReadTimeout = value; + } + + public override int WriteTimeout + { + get => _stream.WriteTimeout; + set => _stream.WriteTimeout = value; + } + + public override void Flush() => _stream.Flush(); + + public override global::System.Threading.Tasks.Task FlushAsync( + 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 global::System.Threading.Tasks.Task ReadAsync( + byte[] buffer, + int offset, + int count, + global::System.Threading.CancellationToken cancellationToken) => + _stream.ReadAsync(buffer, offset, count, cancellationToken); + +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_0_OR_GREATER || NET5_0_OR_GREATER + public override global::System.Threading.Tasks.ValueTask ReadAsync( + global::System.Memory buffer, + global::System.Threading.CancellationToken cancellationToken = default) => + _stream.ReadAsync(buffer, cancellationToken); +#endif + + public override long Seek(long offset, global::System.IO.SeekOrigin origin) => + _stream.Seek(offset, origin); + + public override void SetLength(long value) => + _stream.SetLength(value); + + public override void Write(byte[] buffer, int offset, int count) => + _stream.Write(buffer, offset, count); + + public override global::System.Threading.Tasks.Task WriteAsync( + byte[] buffer, + int offset, + int count, + global::System.Threading.CancellationToken cancellationToken) => + _stream.WriteAsync(buffer, offset, count, cancellationToken); + +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_0_OR_GREATER || NET5_0_OR_GREATER + public override global::System.Threading.Tasks.ValueTask WriteAsync( + global::System.ReadOnlyMemory buffer, + global::System.Threading.CancellationToken cancellationToken = default) => + _stream.WriteAsync(buffer, cancellationToken); +#endif + + protected override void Dispose(bool disposing) + { + if (!_disposed && disposing) + { + _disposed = true; + _stream.Dispose(); + _response.Dispose(); + } + + base.Dispose(disposing); + } + +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_0_OR_GREATER || NET5_0_OR_GREATER + public override async global::System.Threading.Tasks.ValueTask DisposeAsync() + { + if (_disposed) + { + return; + } + + _disposed = true; + await _stream.DisposeAsync().ConfigureAwait(false); + _response.Dispose(); + await base.DisposeAsync().ConfigureAwait(false); + } +#endif + } +} \ No newline at end of file diff --git a/src/libs/Simli/Generated/Simli.SimliClient.EnqueueGSAGenerationFacesGsCreatePost.g.cs b/src/libs/Simli/Generated/Simli.SimliClient.EnqueueGSAGenerationFacesGsCreatePost.g.cs index b2bd5ae..0940f3a 100644 --- a/src/libs/Simli/Generated/Simli.SimliClient.EnqueueGSAGenerationFacesGsCreatePost.g.cs +++ b/src/libs/Simli/Generated/Simli.SimliClient.EnqueueGSAGenerationFacesGsCreatePost.g.cs @@ -169,22 +169,6 @@ partial void ProcessEnqueueGSAGenerationFacesGsCreatePostResponseContent( } var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); - if (gsVersion != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(gsVersion.ToString() ?? string.Empty), - name: "\"gsVersion\""); - - } - if (faceName != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(faceName ?? string.Empty), - name: "\"face_name\""); - - } 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 @@ -682,22 +666,6 @@ request.Imagename is null } var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); - if (gsVersion != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(gsVersion.ToString() ?? string.Empty), - name: "\"gsVersion\""); - - } - if (faceName != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(faceName ?? string.Empty), - name: "\"face_name\""); - - } var __contentImage = new global::System.Net.Http.StreamContent(image); __contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( request.Imagename is null @@ -1151,22 +1119,6 @@ request.Imagename is null } var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); - if (gsVersion != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(gsVersion.ToString() ?? string.Empty), - name: "\"gsVersion\""); - - } - if (faceName != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(faceName ?? string.Empty), - name: "\"face_name\""); - - } var __contentImage = new global::System.Net.Http.StreamContent(image); __contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( request.Imagename is null diff --git a/src/libs/Simli/Generated/Simli.SimliClient.GetCachedVideoMp4StaticMp4MachineIPFileGet.g.cs b/src/libs/Simli/Generated/Simli.SimliClient.GetCachedVideoMp4StaticMp4MachineIPFileGet.g.cs index 5e38544..d7f5a74 100644 --- a/src/libs/Simli/Generated/Simli.SimliClient.GetCachedVideoMp4StaticMp4MachineIPFileGet.g.cs +++ b/src/libs/Simli/Generated/Simli.SimliClient.GetCachedVideoMp4StaticMp4MachineIPFileGet.g.cs @@ -41,7 +41,7 @@ partial void ProcessGetCachedVideoMp4StaticMp4MachineIPFileGetResponse( partial void ProcessGetCachedVideoMp4StaticMp4MachineIPFileGetResponseContent( global::System.Net.Http.HttpClient httpClient, global::System.Net.Http.HttpResponseMessage httpResponseMessage, - ref string content); + ref byte[] content); /// /// Get MP4 of Generated Video @@ -51,7 +51,7 @@ partial void ProcessGetCachedVideoMp4StaticMp4MachineIPFileGetResponseContent( /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// - public async global::System.Threading.Tasks.Task GetCachedVideoMp4StaticMp4MachineIPFileGetAsync( + public async global::System.Threading.Tasks.Task GetCachedVideoMp4StaticMp4MachineIPFileGetAsync( string destination, string file, global::Simli.AutoSDKRequestOptions? requestOptions = default, @@ -74,7 +74,394 @@ partial void ProcessGetCachedVideoMp4StaticMp4MachineIPFileGetResponseContent( /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// - public async global::System.Threading.Tasks.Task> GetCachedVideoMp4StaticMp4MachineIPFileGetAsResponseAsync( + public async global::System.Threading.Tasks.Task GetCachedVideoMp4StaticMp4MachineIPFileGetAsStreamAsync( + 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!, + 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!, + 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!, + 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!, + 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!, + 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.ResponseStream(__response, __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)); + } + + } + catch + { + __response.Dispose(); + throw; + } + } + finally + { + __httpRequest?.Dispose(); + } + } + /// + /// 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 + /// + public async global::System.Threading.Tasks.Task> GetCachedVideoMp4StaticMp4MachineIPFileGetAsResponseAsync( string destination, string file, global::Simli.AutoSDKRequestOptions? requestOptions = default, @@ -405,16 +792,12 @@ partial void ProcessGetCachedVideoMp4StaticMp4MachineIPFileGetResponseContent( if (__effectiveReadResponseAsString) { - var __content = await __response.Content.ReadAsStringAsync( + var __content = await __response.Content.ReadAsByteArrayAsync( #if NET5_0_OR_GREATER __effectiveCancellationToken #endif ).ConfigureAwait(false); - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); ProcessGetCachedVideoMp4StaticMp4MachineIPFileGetResponseContent( httpClient: HttpClient, httpResponseMessage: __response, @@ -424,7 +807,7 @@ partial void ProcessGetCachedVideoMp4StaticMp4MachineIPFileGetResponseContent( { __response.EnsureSuccessStatusCode(); - return new global::Simli.AutoSDKHttpResponse( + return new global::Simli.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Simli.AutoSDKHttpResponse.CreateHeaders(__response), requestUri: __response.RequestMessage?.RequestUri, @@ -434,9 +817,9 @@ partial void ProcessGetCachedVideoMp4StaticMp4MachineIPFileGetResponseContent( { throw global::Simli.ApiException.Create( statusCode: __response.StatusCode, - message: __content ?? __response.ReasonPhrase ?? string.Empty, + message: __response.ReasonPhrase ?? string.Empty, innerException: __ex, - responseBody: __content, + responseBody: null, responseHeaders: global::System.Linq.Enumerable.ToDictionary( __response.Headers, h => h.Key, @@ -448,13 +831,13 @@ partial void ProcessGetCachedVideoMp4StaticMp4MachineIPFileGetResponseContent( try { __response.EnsureSuccessStatusCode(); - var __content = await __response.Content.ReadAsStringAsync( + var __content = await __response.Content.ReadAsByteArrayAsync( #if NET5_0_OR_GREATER __effectiveCancellationToken #endif ).ConfigureAwait(false); - return new global::Simli.AutoSDKHttpResponse( + return new global::Simli.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Simli.AutoSDKHttpResponse.CreateHeaders(__response), requestUri: __response.RequestMessage?.RequestUri, diff --git a/src/libs/Simli/Generated/Simli.SimliClient.GetCachedVideoStaticHlsMachineIPFileGet.g.cs b/src/libs/Simli/Generated/Simli.SimliClient.GetCachedVideoStaticHlsMachineIPFileGet.g.cs index eb7b8c1..ed60098 100644 --- a/src/libs/Simli/Generated/Simli.SimliClient.GetCachedVideoStaticHlsMachineIPFileGet.g.cs +++ b/src/libs/Simli/Generated/Simli.SimliClient.GetCachedVideoStaticHlsMachineIPFileGet.g.cs @@ -41,7 +41,7 @@ partial void ProcessGetCachedVideoStaticHlsMachineIPFileGetResponse( partial void ProcessGetCachedVideoStaticHlsMachineIPFileGetResponseContent( global::System.Net.Http.HttpClient httpClient, global::System.Net.Http.HttpResponseMessage httpResponseMessage, - ref string content); + ref byte[] content); /// /// Get HLS Segment
@@ -52,7 +52,7 @@ partial void ProcessGetCachedVideoStaticHlsMachineIPFileGetResponseContent( /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// - public async global::System.Threading.Tasks.Task GetCachedVideoStaticHlsMachineIPFileGetAsync( + public async global::System.Threading.Tasks.Task GetCachedVideoStaticHlsMachineIPFileGetAsync( string destination, string file, global::Simli.AutoSDKRequestOptions? requestOptions = default, @@ -76,7 +76,395 @@ partial void ProcessGetCachedVideoStaticHlsMachineIPFileGetResponseContent( /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// - public async global::System.Threading.Tasks.Task> GetCachedVideoStaticHlsMachineIPFileGetAsResponseAsync( + public async global::System.Threading.Tasks.Task GetCachedVideoStaticHlsMachineIPFileGetAsStreamAsync( + 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!, + 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!, + 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!, + 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!, + 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!, + 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.ResponseStream(__response, __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)); + } + + } + catch + { + __response.Dispose(); + throw; + } + } + finally + { + __httpRequest?.Dispose(); + } + } + /// + /// 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 + /// + public async global::System.Threading.Tasks.Task> GetCachedVideoStaticHlsMachineIPFileGetAsResponseAsync( string destination, string file, global::Simli.AutoSDKRequestOptions? requestOptions = default, @@ -407,16 +795,12 @@ partial void ProcessGetCachedVideoStaticHlsMachineIPFileGetResponseContent( if (__effectiveReadResponseAsString) { - var __content = await __response.Content.ReadAsStringAsync( + var __content = await __response.Content.ReadAsByteArrayAsync( #if NET5_0_OR_GREATER __effectiveCancellationToken #endif ).ConfigureAwait(false); - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); ProcessGetCachedVideoStaticHlsMachineIPFileGetResponseContent( httpClient: HttpClient, httpResponseMessage: __response, @@ -426,7 +810,7 @@ partial void ProcessGetCachedVideoStaticHlsMachineIPFileGetResponseContent( { __response.EnsureSuccessStatusCode(); - return new global::Simli.AutoSDKHttpResponse( + return new global::Simli.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Simli.AutoSDKHttpResponse.CreateHeaders(__response), requestUri: __response.RequestMessage?.RequestUri, @@ -436,9 +820,9 @@ partial void ProcessGetCachedVideoStaticHlsMachineIPFileGetResponseContent( { throw global::Simli.ApiException.Create( statusCode: __response.StatusCode, - message: __content ?? __response.ReasonPhrase ?? string.Empty, + message: __response.ReasonPhrase ?? string.Empty, innerException: __ex, - responseBody: __content, + responseBody: null, responseHeaders: global::System.Linq.Enumerable.ToDictionary( __response.Headers, h => h.Key, @@ -450,13 +834,13 @@ partial void ProcessGetCachedVideoStaticHlsMachineIPFileGetResponseContent( try { __response.EnsureSuccessStatusCode(); - var __content = await __response.Content.ReadAsStringAsync( + var __content = await __response.Content.ReadAsByteArrayAsync( #if NET5_0_OR_GREATER __effectiveCancellationToken #endif ).ConfigureAwait(false); - return new global::Simli.AutoSDKHttpResponse( + return new global::Simli.AutoSDKHttpResponse( statusCode: __response.StatusCode, headers: global::Simli.AutoSDKHttpResponse.CreateHeaders(__response), requestUri: __response.RequestMessage?.RequestUri, diff --git a/src/libs/Simli/Generated/Simli.SimliClient.PreprocessImageFacesTrinityPreprocessPost.g.cs b/src/libs/Simli/Generated/Simli.SimliClient.PreprocessImageFacesTrinityPreprocessPost.g.cs index f8a9d12..ff1b91c 100644 --- a/src/libs/Simli/Generated/Simli.SimliClient.PreprocessImageFacesTrinityPreprocessPost.g.cs +++ b/src/libs/Simli/Generated/Simli.SimliClient.PreprocessImageFacesTrinityPreprocessPost.g.cs @@ -151,14 +151,6 @@ await PreprocessImageFacesTrinityPreprocessPostAsResponseAsync( } var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); - if (retry != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(retry, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()), - name: "\"retry\""); - - } 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 @@ -603,14 +595,6 @@ await PreprocessImageFacesTrinityPreprocessPostAsync( } var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); - if (retry != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(retry, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()), - name: "\"retry\""); - - } var __contentImage = new global::System.Net.Http.StreamContent(image); __contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( request.Imagename is null @@ -1011,14 +995,6 @@ request.Imagename is null } var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); - if (retry != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(retry, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()), - name: "\"retry\""); - - } var __contentImage = new global::System.Net.Http.StreamContent(image); __contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( request.Imagename is null