diff --git a/src/libs/Simli/Generated/Simli.AutoSDKHttpResponse.g.cs b/src/libs/Simli/Generated/Simli.AutoSDKHttpResponse.g.cs new file mode 100644 index 0000000..73b4bc0 --- /dev/null +++ b/src/libs/Simli/Generated/Simli.AutoSDKHttpResponse.g.cs @@ -0,0 +1,121 @@ + +#nullable enable + +namespace Simli +{ + /// + /// Represents a successful HTTP response with status code and headers. + /// + public partial class AutoSDKHttpResponse + { + /// + /// Initializes a new instance of the class. + /// + public AutoSDKHttpResponse( + global::System.Net.HttpStatusCode statusCode, + global::System.Collections.Generic.Dictionary> headers) + : this( + statusCode: statusCode, + headers: headers, + requestUri: null) + { + } + + /// + /// Initializes a new instance of the class. + /// + public AutoSDKHttpResponse( + global::System.Net.HttpStatusCode statusCode, + global::System.Collections.Generic.Dictionary> headers, + global::System.Uri? requestUri) + { + StatusCode = statusCode; + Headers = headers ?? throw new global::System.ArgumentNullException(nameof(headers)); + RequestUri = requestUri; + } + + /// + /// Gets the HTTP status code. + /// + public global::System.Net.HttpStatusCode StatusCode { get; } + /// + /// Gets the response headers. + /// + public global::System.Collections.Generic.Dictionary> Headers { get; } + /// + /// Gets the final request URI associated with the response. + /// + public global::System.Uri? RequestUri { get; } + + internal static global::System.Collections.Generic.Dictionary> CreateHeaders( + global::System.Net.Http.HttpResponseMessage response) + { + response = response ?? throw new global::System.ArgumentNullException(nameof(response)); + + var headers = global::System.Linq.Enumerable.ToDictionary( + response.Headers, + static header => header.Key, + static header => (global::System.Collections.Generic.IEnumerable)global::System.Linq.Enumerable.ToArray(header.Value), + global::System.StringComparer.OrdinalIgnoreCase); + + if (response.Content?.Headers == null) + { + return headers; + } + + foreach (var header in response.Content.Headers) + { + if (headers.TryGetValue(header.Key, out var existingValues)) + { + headers[header.Key] = global::System.Linq.Enumerable.ToArray( + global::System.Linq.Enumerable.Concat(existingValues, header.Value)); + } + else + { + headers[header.Key] = global::System.Linq.Enumerable.ToArray(header.Value); + } + } + + return headers; + } + } + + /// + /// Represents a successful HTTP response with status code, headers, and body. + /// + public partial class AutoSDKHttpResponse : AutoSDKHttpResponse + { + /// + /// Initializes a new instance of the class. + /// + public AutoSDKHttpResponse( + global::System.Net.HttpStatusCode statusCode, + global::System.Collections.Generic.Dictionary> headers, + T body) + : this( + statusCode: statusCode, + headers: headers, + requestUri: null, + body: body) + { + } + + /// + /// Initializes a new instance of the class. + /// + public AutoSDKHttpResponse( + global::System.Net.HttpStatusCode statusCode, + global::System.Collections.Generic.Dictionary> headers, + global::System.Uri? requestUri, + T body) + : base(statusCode, headers, requestUri) + { + Body = body; + } + + /// + /// Gets the response body. + /// + public T Body { get; } + } +} \ No newline at end of file diff --git a/src/libs/Simli/Generated/Simli.ISimliClient.AudioToVideoInterfaceStaticAudioPost.g.cs b/src/libs/Simli/Generated/Simli.ISimliClient.AudioToVideoInterfaceStaticAudioPost.g.cs index 3d0c191..e35eeaa 100644 --- a/src/libs/Simli/Generated/Simli.ISimliClient.AudioToVideoInterfaceStaticAudioPost.g.cs +++ b/src/libs/Simli/Generated/Simli.ISimliClient.AudioToVideoInterfaceStaticAudioPost.g.cs @@ -21,6 +21,19 @@ public partial interface ISimliClient /// Generate Static Video
/// Generate and stream a static video file from a given audio sample /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> AudioToVideoInterfaceStaticAudioPostAsResponseAsync( + + global::Simli.AudioToVideoRequest request, + global::Simli.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Generate Static Video
+ /// Generate and stream a static video file from a given audio sample + ///
/// /// /// diff --git a/src/libs/Simli/Generated/Simli.ISimliClient.DeleteFacesTrinityById.g.cs b/src/libs/Simli/Generated/Simli.ISimliClient.DeleteFacesTrinityById.g.cs index 6e2f383..142cffa 100644 --- a/src/libs/Simli/Generated/Simli.ISimliClient.DeleteFacesTrinityById.g.cs +++ b/src/libs/Simli/Generated/Simli.ISimliClient.DeleteFacesTrinityById.g.cs @@ -16,5 +16,17 @@ public partial interface ISimliClient global::System.Guid id, global::Simli.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Delete a face
+ /// Removes a face. This can not be undone. All agents connected to this face_id will be broken + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task DeleteFacesTrinityByIdAsResponseAsync( + global::System.Guid id, + global::Simli.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Simli/Generated/Simli.ISimliClient.EnqueueGSAGenerationFacesGsCreatePost.g.cs b/src/libs/Simli/Generated/Simli.ISimliClient.EnqueueGSAGenerationFacesGsCreatePost.g.cs index d27332c..6aac316 100644 --- a/src/libs/Simli/Generated/Simli.ISimliClient.EnqueueGSAGenerationFacesGsCreatePost.g.cs +++ b/src/libs/Simli/Generated/Simli.ISimliClient.EnqueueGSAGenerationFacesGsCreatePost.g.cs @@ -33,6 +33,26 @@ public partial interface ISimliClient /// /// Default Value: untitled_avatar /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> EnqueueGSAGenerationFacesGsCreatePostAsResponseAsync( + + global::Simli.BodyEnqueueGSAGenerationFacesGsCreatePost request, + global::Simli.TrinityVersion? gsVersion = default, + string? faceName = default, + global::Simli.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Generate Trinity Face + /// + /// + /// Default Value: GSA_1.0 + /// + /// + /// Default Value: untitled_avatar + /// /// /// /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. @@ -45,5 +65,52 @@ public partial interface ISimliClient string? faceName = default, global::Simli.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); + + /// + /// Generate Trinity Face + /// + /// + /// Default Value: GSA_1.0 + /// + /// + /// Default Value: untitled_avatar + /// + /// + /// The stream to send as the multipart 'image' file part. + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task EnqueueGSAGenerationFacesGsCreatePostAsync( + global::System.IO.Stream image, + string imagename, + global::Simli.TrinityVersion? gsVersion = default, + string? faceName = default, + global::Simli.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Generate Trinity Face + /// + /// + /// Default Value: GSA_1.0 + /// + /// + /// Default Value: untitled_avatar + /// + /// + /// The stream to send as the multipart 'image' file part. + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> EnqueueGSAGenerationFacesGsCreatePostAsResponseAsync( + global::System.IO.Stream image, + string imagename, + global::Simli.TrinityVersion? gsVersion = default, + string? faceName = default, + global::Simli.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Simli/Generated/Simli.ISimliClient.GetCachedVideoMp4StaticMp4MachineIPFileGet.g.cs b/src/libs/Simli/Generated/Simli.ISimliClient.GetCachedVideoMp4StaticMp4MachineIPFileGet.g.cs index 2fc081c..d4b0caa 100644 --- a/src/libs/Simli/Generated/Simli.ISimliClient.GetCachedVideoMp4StaticMp4MachineIPFileGet.g.cs +++ b/src/libs/Simli/Generated/Simli.ISimliClient.GetCachedVideoMp4StaticMp4MachineIPFileGet.g.cs @@ -17,5 +17,18 @@ public partial interface ISimliClient 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, + global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Simli/Generated/Simli.ISimliClient.GetCachedVideoStaticHlsMachineIPFileGet.g.cs b/src/libs/Simli/Generated/Simli.ISimliClient.GetCachedVideoStaticHlsMachineIPFileGet.g.cs index 2513ae2..979f604 100644 --- a/src/libs/Simli/Generated/Simli.ISimliClient.GetCachedVideoStaticHlsMachineIPFileGet.g.cs +++ b/src/libs/Simli/Generated/Simli.ISimliClient.GetCachedVideoStaticHlsMachineIPFileGet.g.cs @@ -18,5 +18,19 @@ public partial interface ISimliClient 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, + global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Simli/Generated/Simli.ISimliClient.GetFaces.g.cs b/src/libs/Simli/Generated/Simli.ISimliClient.GetFaces.g.cs index 32e3484..062dbff 100644 --- a/src/libs/Simli/Generated/Simli.ISimliClient.GetFaces.g.cs +++ b/src/libs/Simli/Generated/Simli.ISimliClient.GetFaces.g.cs @@ -13,5 +13,14 @@ public partial interface ISimliClient global::System.Threading.Tasks.Task> GetFacesAsync( global::Simli.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Get all faces + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task>> GetFacesAsResponseAsync( + global::Simli.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Simli/Generated/Simli.ISimliClient.GetHistorySessions.g.cs b/src/libs/Simli/Generated/Simli.ISimliClient.GetHistorySessions.g.cs index 2c2e18f..0ecf9aa 100644 --- a/src/libs/Simli/Generated/Simli.ISimliClient.GetHistorySessions.g.cs +++ b/src/libs/Simli/Generated/Simli.ISimliClient.GetHistorySessions.g.cs @@ -22,5 +22,23 @@ public partial interface ISimliClient int? end = default, global::Simli.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Retrieve session history
+ /// Returns a list of session history records for the authenticated user + ///
+ /// + /// Example: 1745750387 + /// + /// + /// Example: 1745750408 + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> GetHistorySessionsAsResponseAsync( + int? start = default, + int? end = default, + global::Simli.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Simli/Generated/Simli.ISimliClient.GetIceServersComposeIceGet.g.cs b/src/libs/Simli/Generated/Simli.ISimliClient.GetIceServersComposeIceGet.g.cs index 17931c1..1ed0e4f 100644 --- a/src/libs/Simli/Generated/Simli.ISimliClient.GetIceServersComposeIceGet.g.cs +++ b/src/libs/Simli/Generated/Simli.ISimliClient.GetIceServersComposeIceGet.g.cs @@ -14,5 +14,15 @@ public partial interface ISimliClient global::System.Threading.Tasks.Task> GetIceServersComposeIceGetAsync( global::Simli.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Get Ice Servers
+ /// Create a new set of temporary ICE Server Credentials for WebRTC P2P session + ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task>> GetIceServersComposeIceGetAsResponseAsync( + global::Simli.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Simli/Generated/Simli.ISimliClient.GetRatelimiterSessions.g.cs b/src/libs/Simli/Generated/Simli.ISimliClient.GetRatelimiterSessions.g.cs index 635f246..b263e49 100644 --- a/src/libs/Simli/Generated/Simli.ISimliClient.GetRatelimiterSessions.g.cs +++ b/src/libs/Simli/Generated/Simli.ISimliClient.GetRatelimiterSessions.g.cs @@ -13,5 +13,14 @@ public partial interface ISimliClient global::System.Threading.Tasks.Task GetRatelimiterSessionsAsync( global::Simli.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Active Session Count + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> GetRatelimiterSessionsAsResponseAsync( + global::Simli.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Simli/Generated/Simli.ISimliClient.GetRequestStatusFacesGsStatusGet.g.cs b/src/libs/Simli/Generated/Simli.ISimliClient.GetRequestStatusFacesGsStatusGet.g.cs index 4b1e8a6..5b9e8d4 100644 --- a/src/libs/Simli/Generated/Simli.ISimliClient.GetRequestStatusFacesGsStatusGet.g.cs +++ b/src/libs/Simli/Generated/Simli.ISimliClient.GetRequestStatusFacesGsStatusGet.g.cs @@ -15,5 +15,16 @@ public partial interface ISimliClient string? faceId = default, global::Simli.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Check Trinity Generation Status + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> GetRequestStatusFacesGsStatusGetAsResponseAsync( + string? faceId = default, + global::Simli.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Simli/Generated/Simli.ISimliClient.InitIntegrationsLivekitAgentsPost.g.cs b/src/libs/Simli/Generated/Simli.ISimliClient.InitIntegrationsLivekitAgentsPost.g.cs index 7a44262..0226bf5 100644 --- a/src/libs/Simli/Generated/Simli.ISimliClient.InitIntegrationsLivekitAgentsPost.g.cs +++ b/src/libs/Simli/Generated/Simli.ISimliClient.InitIntegrationsLivekitAgentsPost.g.cs @@ -19,6 +19,18 @@ public partial interface ISimliClient /// /// Start Livekit Agents Session /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> InitIntegrationsLivekitAgentsPostAsResponseAsync( + + global::Simli.LiveKitInitializationRequest request, + global::Simli.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Start Livekit Agents Session + /// /// /// /// diff --git a/src/libs/Simli/Generated/Simli.ISimliClient.StartAudioToVideoSessionComposeTokenPost.g.cs b/src/libs/Simli/Generated/Simli.ISimliClient.StartAudioToVideoSessionComposeTokenPost.g.cs index cc2ccff..1b9d7bd 100644 --- a/src/libs/Simli/Generated/Simli.ISimliClient.StartAudioToVideoSessionComposeTokenPost.g.cs +++ b/src/libs/Simli/Generated/Simli.ISimliClient.StartAudioToVideoSessionComposeTokenPost.g.cs @@ -21,6 +21,19 @@ public partial interface ISimliClient /// Compose Session Token
/// Create a temporary Simli Compose Session Token /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> StartAudioToVideoSessionComposeTokenPostAsResponseAsync( + + global::Simli.StartStreamingSessionRequest request, + global::Simli.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Compose Session Token
+ /// Create a temporary Simli Compose Session Token + ///
/// /// /// diff --git a/src/libs/Simli/Generated/Simli.OptionsSupport.g.cs b/src/libs/Simli/Generated/Simli.OptionsSupport.g.cs index 0fe288b..a2aa640 100644 --- a/src/libs/Simli/Generated/Simli.OptionsSupport.g.cs +++ b/src/libs/Simli/Generated/Simli.OptionsSupport.g.cs @@ -101,9 +101,45 @@ public sealed class AutoSDKRetryOptions public int MaxAttempts { get; set; } = 1; /// - /// Optional fixed delay between retry attempts. + /// Optional fixed delay between retry attempts. When set, this takes precedence over exponential backoff. /// public global::System.TimeSpan? Delay { get; set; } + + /// + /// Initial exponential backoff delay used when is not set. + /// + public global::System.TimeSpan InitialDelay { get; set; } = global::System.TimeSpan.FromSeconds(1); + + /// + /// Maximum retry delay after applying retry headers, backoff, and jitter. + /// + public global::System.TimeSpan MaxDelay { get; set; } = global::System.TimeSpan.FromSeconds(30); + + /// + /// Multiplier applied to exponential backoff after each failed attempt. + /// Values below 1 are normalized to 1. + /// + public double BackoffMultiplier { get; set; } = 2D; + + /// + /// Randomizes computed backoff by plus or minus this ratio. Values are clamped to 0..1. + /// + public double JitterRatio { get; set; } = 0.2D; + + /// + /// Whether Retry-After response headers should control retry delay when present. + /// + public bool UseRetryAfterHeader { get; set; } = true; + + /// + /// Whether a rate-limit reset response header should control retry delay when present. + /// + public bool UseRateLimitResetHeader { get; set; } + + /// + /// Optional provider-specific rate-limit reset header name. Values may be Unix seconds or an HTTP date. + /// + public string? RateLimitResetHeaderName { get; set; } = "X-RateLimit-Reset"; } @@ -231,6 +267,16 @@ public sealed class AutoSDKHookContext /// public bool WillRetry { get; set; } + /// + /// The computed retry delay when is true. + /// + public global::System.TimeSpan? RetryDelay { get; set; } + + /// + /// A short retry reason such as exception or status:429. + /// + public string RetryReason { get; set; } = string.Empty; + /// /// The effective cancellation token for the current request attempt. /// @@ -254,6 +300,8 @@ internal static class AutoSDKRequestOptionsSupport int attempt, int maxAttempts, bool willRetry, + global::System.TimeSpan? retryDelay, + string retryReason, global::System.Threading.CancellationToken cancellationToken) { return new global::Simli.AutoSDKHookContext @@ -271,6 +319,8 @@ internal static class AutoSDKRequestOptionsSupport Attempt = attempt, MaxAttempts = maxAttempts, WillRetry = willRetry, + RetryDelay = retryDelay, + RetryReason = retryReason ?? string.Empty, CancellationToken = cancellationToken, }; } @@ -338,19 +388,188 @@ internal static int GetMaxAttempts( return maxAttempts < 1 ? 1 : maxAttempts; } - internal static async global::System.Threading.Tasks.Task DelayBeforeRetryAsync( + internal static global::System.TimeSpan GetRetryDelay( global::Simli.AutoSDKClientOptions clientOptions, global::Simli.AutoSDKRequestOptions? requestOptions, + global::System.Net.Http.HttpResponseMessage? response, + int attempt) + { + var retryOptions = requestOptions?.Retry ?? clientOptions.Retry ?? new global::Simli.AutoSDKRetryOptions(); + + if (retryOptions.UseRetryAfterHeader && + TryGetRetryAfterDelay(response, out var retryAfterDelay)) + { + return ClampRetryDelay(retryAfterDelay, retryOptions); + } + + if (retryOptions.UseRateLimitResetHeader && + TryGetRateLimitResetDelay(response, retryOptions.RateLimitResetHeaderName, out var rateLimitResetDelay)) + { + return ClampRetryDelay(rateLimitResetDelay, retryOptions); + } + + if (retryOptions.Delay.HasValue) + { + return ClampRetryDelay(retryOptions.Delay.Value, retryOptions); + } + + var initialDelay = retryOptions.InitialDelay; + if (initialDelay <= global::System.TimeSpan.Zero) + { + return global::System.TimeSpan.Zero; + } + + var multiplier = retryOptions.BackoffMultiplier < 1D ? 1D : retryOptions.BackoffMultiplier; + var exponent = attempt <= 1 ? 0 : attempt - 1; + var delayMilliseconds = initialDelay.TotalMilliseconds * global::System.Math.Pow(multiplier, exponent); + if (double.IsNaN(delayMilliseconds) || double.IsInfinity(delayMilliseconds) || delayMilliseconds < 0D) + { + delayMilliseconds = 0D; + } + + var delay = global::System.TimeSpan.FromMilliseconds(delayMilliseconds); + delay = ApplyJitter(delay, retryOptions.JitterRatio); + return ClampRetryDelay(delay, retryOptions); + } + + internal static async global::System.Threading.Tasks.Task DelayBeforeRetryAsync( + global::System.TimeSpan retryDelay, global::System.Threading.CancellationToken cancellationToken) { - var delay = requestOptions?.Retry?.Delay ?? - clientOptions.Retry?.Delay; - if (!delay.HasValue || delay.Value <= global::System.TimeSpan.Zero) + if (retryDelay <= global::System.TimeSpan.Zero) { return; } - await global::System.Threading.Tasks.Task.Delay(delay.Value, cancellationToken).ConfigureAwait(false); + await global::System.Threading.Tasks.Task.Delay(retryDelay, cancellationToken).ConfigureAwait(false); + } + + private static bool TryGetRetryAfterDelay( + global::System.Net.Http.HttpResponseMessage? response, + out global::System.TimeSpan delay) + { + delay = global::System.TimeSpan.Zero; + var retryAfter = response?.Headers.RetryAfter; + if (retryAfter == null) + { + return false; + } + + if (retryAfter.Delta.HasValue) + { + delay = retryAfter.Delta.Value; + return delay > global::System.TimeSpan.Zero; + } + + if (retryAfter.Date.HasValue) + { + delay = retryAfter.Date.Value - global::System.DateTimeOffset.UtcNow; + return delay > global::System.TimeSpan.Zero; + } + + return false; + } + + private static bool TryGetRateLimitResetDelay( + global::System.Net.Http.HttpResponseMessage? response, + string? headerName, + out global::System.TimeSpan delay) + { + delay = global::System.TimeSpan.Zero; + if (response == null || string.IsNullOrWhiteSpace(headerName)) + { + return false; + } + + if (!response.Headers.TryGetValues(headerName, out var values) && + (response.Content?.Headers == null || !response.Content.Headers.TryGetValues(headerName, out values))) + { + return false; + } + + var value = global::System.Linq.Enumerable.FirstOrDefault(values); + if (string.IsNullOrWhiteSpace(value)) + { + return false; + } + + value = value.Trim(); + if (long.TryParse( + value, + global::System.Globalization.NumberStyles.Integer, + global::System.Globalization.CultureInfo.InvariantCulture, + out var unixSeconds)) + { + delay = global::System.DateTimeOffset.FromUnixTimeSeconds(unixSeconds) - global::System.DateTimeOffset.UtcNow; + return delay > global::System.TimeSpan.Zero; + } + + if (global::System.DateTimeOffset.TryParse( + value, + global::System.Globalization.CultureInfo.InvariantCulture, + global::System.Globalization.DateTimeStyles.AssumeUniversal | global::System.Globalization.DateTimeStyles.AdjustToUniversal, + out var resetAt)) + { + delay = resetAt - global::System.DateTimeOffset.UtcNow; + return delay > global::System.TimeSpan.Zero; + } + + return false; + } + + private static global::System.TimeSpan ApplyJitter( + global::System.TimeSpan delay, + double jitterRatio) + { + if (delay <= global::System.TimeSpan.Zero || jitterRatio <= 0D) + { + return delay; + } + + if (jitterRatio > 1D) + { + jitterRatio = 1D; + } + + var sample = NextJitterSample(); + var multiplier = 1D - jitterRatio + (sample * jitterRatio * 2D); + var milliseconds = delay.TotalMilliseconds * multiplier; + if (double.IsNaN(milliseconds) || double.IsInfinity(milliseconds) || milliseconds < 0D) + { + milliseconds = 0D; + } + + return global::System.TimeSpan.FromMilliseconds(milliseconds); + } + + private static double NextJitterSample() + { + var bytes = new byte[8]; + using (var randomNumberGenerator = global::System.Security.Cryptography.RandomNumberGenerator.Create()) + { + randomNumberGenerator.GetBytes(bytes); + } + + var value = global::System.BitConverter.ToUInt64(bytes, 0); + return value / (double)ulong.MaxValue; + } + + private static global::System.TimeSpan ClampRetryDelay( + global::System.TimeSpan delay, + global::Simli.AutoSDKRetryOptions retryOptions) + { + if (delay <= global::System.TimeSpan.Zero) + { + return global::System.TimeSpan.Zero; + } + + var maxDelay = retryOptions.MaxDelay; + if (maxDelay > global::System.TimeSpan.Zero && delay > maxDelay) + { + return maxDelay; + } + + return delay; } internal static bool ShouldRetryStatusCode( diff --git a/src/libs/Simli/Generated/Simli.Realtime.OptionsSupport.g.cs b/src/libs/Simli/Generated/Simli.Realtime.OptionsSupport.g.cs index d72dd6c..8a409de 100644 --- a/src/libs/Simli/Generated/Simli.Realtime.OptionsSupport.g.cs +++ b/src/libs/Simli/Generated/Simli.Realtime.OptionsSupport.g.cs @@ -101,9 +101,45 @@ public sealed class AutoSDKRetryOptions public int MaxAttempts { get; set; } = 1; /// - /// Optional fixed delay between retry attempts. + /// Optional fixed delay between retry attempts. When set, this takes precedence over exponential backoff. /// public global::System.TimeSpan? Delay { get; set; } + + /// + /// Initial exponential backoff delay used when is not set. + /// + public global::System.TimeSpan InitialDelay { get; set; } = global::System.TimeSpan.FromSeconds(1); + + /// + /// Maximum retry delay after applying retry headers, backoff, and jitter. + /// + public global::System.TimeSpan MaxDelay { get; set; } = global::System.TimeSpan.FromSeconds(30); + + /// + /// Multiplier applied to exponential backoff after each failed attempt. + /// Values below 1 are normalized to 1. + /// + public double BackoffMultiplier { get; set; } = 2D; + + /// + /// Randomizes computed backoff by plus or minus this ratio. Values are clamped to 0..1. + /// + public double JitterRatio { get; set; } = 0.2D; + + /// + /// Whether Retry-After response headers should control retry delay when present. + /// + public bool UseRetryAfterHeader { get; set; } = true; + + /// + /// Whether a rate-limit reset response header should control retry delay when present. + /// + public bool UseRateLimitResetHeader { get; set; } + + /// + /// Optional provider-specific rate-limit reset header name. Values may be Unix seconds or an HTTP date. + /// + public string? RateLimitResetHeaderName { get; set; } = "X-RateLimit-Reset"; } @@ -231,6 +267,16 @@ public sealed class AutoSDKHookContext /// public bool WillRetry { get; set; } + /// + /// The computed retry delay when is true. + /// + public global::System.TimeSpan? RetryDelay { get; set; } + + /// + /// A short retry reason such as exception or status:429. + /// + public string RetryReason { get; set; } = string.Empty; + /// /// The effective cancellation token for the current request attempt. /// @@ -254,6 +300,8 @@ internal static class AutoSDKRequestOptionsSupport int attempt, int maxAttempts, bool willRetry, + global::System.TimeSpan? retryDelay, + string retryReason, global::System.Threading.CancellationToken cancellationToken) { return new global::Simli.Realtime.AutoSDKHookContext @@ -271,6 +319,8 @@ internal static class AutoSDKRequestOptionsSupport Attempt = attempt, MaxAttempts = maxAttempts, WillRetry = willRetry, + RetryDelay = retryDelay, + RetryReason = retryReason ?? string.Empty, CancellationToken = cancellationToken, }; } @@ -338,19 +388,188 @@ internal static int GetMaxAttempts( return maxAttempts < 1 ? 1 : maxAttempts; } - internal static async global::System.Threading.Tasks.Task DelayBeforeRetryAsync( + internal static global::System.TimeSpan GetRetryDelay( global::Simli.Realtime.AutoSDKClientOptions clientOptions, global::Simli.Realtime.AutoSDKRequestOptions? requestOptions, + global::System.Net.Http.HttpResponseMessage? response, + int attempt) + { + var retryOptions = requestOptions?.Retry ?? clientOptions.Retry ?? new global::Simli.Realtime.AutoSDKRetryOptions(); + + if (retryOptions.UseRetryAfterHeader && + TryGetRetryAfterDelay(response, out var retryAfterDelay)) + { + return ClampRetryDelay(retryAfterDelay, retryOptions); + } + + if (retryOptions.UseRateLimitResetHeader && + TryGetRateLimitResetDelay(response, retryOptions.RateLimitResetHeaderName, out var rateLimitResetDelay)) + { + return ClampRetryDelay(rateLimitResetDelay, retryOptions); + } + + if (retryOptions.Delay.HasValue) + { + return ClampRetryDelay(retryOptions.Delay.Value, retryOptions); + } + + var initialDelay = retryOptions.InitialDelay; + if (initialDelay <= global::System.TimeSpan.Zero) + { + return global::System.TimeSpan.Zero; + } + + var multiplier = retryOptions.BackoffMultiplier < 1D ? 1D : retryOptions.BackoffMultiplier; + var exponent = attempt <= 1 ? 0 : attempt - 1; + var delayMilliseconds = initialDelay.TotalMilliseconds * global::System.Math.Pow(multiplier, exponent); + if (double.IsNaN(delayMilliseconds) || double.IsInfinity(delayMilliseconds) || delayMilliseconds < 0D) + { + delayMilliseconds = 0D; + } + + var delay = global::System.TimeSpan.FromMilliseconds(delayMilliseconds); + delay = ApplyJitter(delay, retryOptions.JitterRatio); + return ClampRetryDelay(delay, retryOptions); + } + + internal static async global::System.Threading.Tasks.Task DelayBeforeRetryAsync( + global::System.TimeSpan retryDelay, global::System.Threading.CancellationToken cancellationToken) { - var delay = requestOptions?.Retry?.Delay ?? - clientOptions.Retry?.Delay; - if (!delay.HasValue || delay.Value <= global::System.TimeSpan.Zero) + if (retryDelay <= global::System.TimeSpan.Zero) { return; } - await global::System.Threading.Tasks.Task.Delay(delay.Value, cancellationToken).ConfigureAwait(false); + await global::System.Threading.Tasks.Task.Delay(retryDelay, cancellationToken).ConfigureAwait(false); + } + + private static bool TryGetRetryAfterDelay( + global::System.Net.Http.HttpResponseMessage? response, + out global::System.TimeSpan delay) + { + delay = global::System.TimeSpan.Zero; + var retryAfter = response?.Headers.RetryAfter; + if (retryAfter == null) + { + return false; + } + + if (retryAfter.Delta.HasValue) + { + delay = retryAfter.Delta.Value; + return delay > global::System.TimeSpan.Zero; + } + + if (retryAfter.Date.HasValue) + { + delay = retryAfter.Date.Value - global::System.DateTimeOffset.UtcNow; + return delay > global::System.TimeSpan.Zero; + } + + return false; + } + + private static bool TryGetRateLimitResetDelay( + global::System.Net.Http.HttpResponseMessage? response, + string? headerName, + out global::System.TimeSpan delay) + { + delay = global::System.TimeSpan.Zero; + if (response == null || string.IsNullOrWhiteSpace(headerName)) + { + return false; + } + + if (!response.Headers.TryGetValues(headerName, out var values) && + (response.Content?.Headers == null || !response.Content.Headers.TryGetValues(headerName, out values))) + { + return false; + } + + var value = global::System.Linq.Enumerable.FirstOrDefault(values); + if (string.IsNullOrWhiteSpace(value)) + { + return false; + } + + value = value.Trim(); + if (long.TryParse( + value, + global::System.Globalization.NumberStyles.Integer, + global::System.Globalization.CultureInfo.InvariantCulture, + out var unixSeconds)) + { + delay = global::System.DateTimeOffset.FromUnixTimeSeconds(unixSeconds) - global::System.DateTimeOffset.UtcNow; + return delay > global::System.TimeSpan.Zero; + } + + if (global::System.DateTimeOffset.TryParse( + value, + global::System.Globalization.CultureInfo.InvariantCulture, + global::System.Globalization.DateTimeStyles.AssumeUniversal | global::System.Globalization.DateTimeStyles.AdjustToUniversal, + out var resetAt)) + { + delay = resetAt - global::System.DateTimeOffset.UtcNow; + return delay > global::System.TimeSpan.Zero; + } + + return false; + } + + private static global::System.TimeSpan ApplyJitter( + global::System.TimeSpan delay, + double jitterRatio) + { + if (delay <= global::System.TimeSpan.Zero || jitterRatio <= 0D) + { + return delay; + } + + if (jitterRatio > 1D) + { + jitterRatio = 1D; + } + + var sample = NextJitterSample(); + var multiplier = 1D - jitterRatio + (sample * jitterRatio * 2D); + var milliseconds = delay.TotalMilliseconds * multiplier; + if (double.IsNaN(milliseconds) || double.IsInfinity(milliseconds) || milliseconds < 0D) + { + milliseconds = 0D; + } + + return global::System.TimeSpan.FromMilliseconds(milliseconds); + } + + private static double NextJitterSample() + { + var bytes = new byte[8]; + using (var randomNumberGenerator = global::System.Security.Cryptography.RandomNumberGenerator.Create()) + { + randomNumberGenerator.GetBytes(bytes); + } + + var value = global::System.BitConverter.ToUInt64(bytes, 0); + return value / (double)ulong.MaxValue; + } + + private static global::System.TimeSpan ClampRetryDelay( + global::System.TimeSpan delay, + global::Simli.Realtime.AutoSDKRetryOptions retryOptions) + { + if (delay <= global::System.TimeSpan.Zero) + { + return global::System.TimeSpan.Zero; + } + + var maxDelay = retryOptions.MaxDelay; + if (maxDelay > global::System.TimeSpan.Zero && delay > maxDelay) + { + return maxDelay; + } + + return delay; } internal static bool ShouldRetryStatusCode( diff --git a/src/libs/Simli/Generated/Simli.Realtime.SimliLivekitRealtimeClient.g.cs b/src/libs/Simli/Generated/Simli.Realtime.SimliLivekitRealtimeClient.g.cs index d0777ff..abe9b20 100644 --- a/src/libs/Simli/Generated/Simli.Realtime.SimliLivekitRealtimeClient.g.cs +++ b/src/libs/Simli/Generated/Simli.Realtime.SimliLivekitRealtimeClient.g.cs @@ -13,7 +13,252 @@ public sealed partial class SimliLivekitRealtimeClient : global::System.IDisposa /// public const string DefaultBaseUrl = "wss://api.simli.ai/compose/webrtc/livekit"; - private readonly global::System.Net.WebSockets.ClientWebSocket _clientWebSocket; + private global::System.Net.WebSockets.ClientWebSocket _clientWebSocket; + private global::System.Uri? _lastConnectUri; + private global::System.Collections.Generic.Dictionary? _lastAdditionalHeaders; + private global::System.Collections.Generic.List? _lastAdditionalSubProtocols; + private global::System.TimeSpan? _lastKeepAliveInterval; + private global::System.TimeSpan? _lastConnectTimeout; + + + /// + /// Current WebSocket connection status. + /// + public enum AutoSDKWebSocketConnectionStatus + { + /// + /// The client is not connected. + /// + Disconnected, + + /// + /// The client is connecting. + /// + Connecting, + + /// + /// The client is connected. + /// + Connected, + + /// + /// The client observed a normal close. + /// + Closed, + + /// + /// The client observed a connection error. + /// + Faulted, + } + + /// + /// Configures automatic reconnect attempts after receive-loop WebSocket failures. + /// + public sealed class AutoSDKWebSocketReconnectOptions + { + /// + /// Enables reconnect attempts from the receive loop. + /// + public bool Enabled { get; set; } + + /// + /// Maximum reconnect attempts per observed receive failure. + /// + public int MaxAttempts { get; set; } = 3; + + /// + /// Delay before the first reconnect attempt. + /// + public global::System.TimeSpan InitialDelay { get; set; } = global::System.TimeSpan.FromSeconds(1); + + /// + /// Maximum delay between reconnect attempts. + /// + public global::System.TimeSpan MaxDelay { get; set; } = global::System.TimeSpan.FromSeconds(30); + + /// + /// Multiplier applied to the delay after each failed reconnect attempt. + /// + public double BackoffMultiplier { get; set; } = 2D; + } + + /// + /// Event data for closed WebSocket connections. + /// + public sealed class AutoSDKWebSocketClosedEventArgs : global::System.EventArgs + { + /// + /// Initializes a new instance of the class. + /// + public AutoSDKWebSocketClosedEventArgs( + global::System.Net.WebSockets.WebSocketCloseStatus? closeStatus, + string? closeStatusDescription) + { + CloseStatus = closeStatus; + CloseStatusDescription = closeStatusDescription; + } + + /// + /// Gets the WebSocket close status. + /// + public global::System.Net.WebSockets.WebSocketCloseStatus? CloseStatus { get; } + + /// + /// Gets the WebSocket close status description. + /// + public string? CloseStatusDescription { get; } + } + + /// + /// Event data for WebSocket exceptions. + /// + public sealed class AutoSDKWebSocketExceptionEventArgs : global::System.EventArgs + { + /// + /// Initializes a new instance of the class. + /// + public AutoSDKWebSocketExceptionEventArgs( + global::System.Exception exception) + { + Exception = exception ?? throw new global::System.ArgumentNullException(nameof(exception)); + } + + /// + /// Gets the observed exception. + /// + public global::System.Exception Exception { get; } + } + + /// + /// Event data for WebSocket reconnect attempts. + /// + public sealed class AutoSDKWebSocketReconnectEventArgs : global::System.EventArgs + { + /// + /// Initializes a new instance of the class. + /// + public AutoSDKWebSocketReconnectEventArgs( + int attempt, + global::System.TimeSpan delay, + global::System.Exception exception) + { + Attempt = attempt; + Delay = delay; + Exception = exception ?? throw new global::System.ArgumentNullException(nameof(exception)); + } + + /// + /// Gets the reconnect attempt number. + /// + public int Attempt { get; } + + /// + /// Gets the delay before the reconnect attempt. + /// + public global::System.TimeSpan Delay { get; } + + /// + /// Gets the exception that triggered reconnect. + /// + public global::System.Exception Exception { get; } + } + + /// + /// Event data for deserialized WebSocket messages. + /// + public sealed class AutoSDKWebSocketMessageEventArgs : global::System.EventArgs + { + /// + /// Initializes a new instance of the class. + /// + public AutoSDKWebSocketMessageEventArgs( + TMessage message, + string rawText, + global::System.Text.Json.JsonElement? json) + { + Message = message; + RawText = rawText ?? string.Empty; + Json = json; + } + + /// + /// Gets the deserialized message. + /// + public TMessage Message { get; } + + /// + /// Gets the raw text received from the WebSocket. + /// + public string RawText { get; } + + /// + /// Gets the parsed JSON payload when available. + /// + public global::System.Text.Json.JsonElement? Json { get; } + } + + /// + /// Event data for messages that could not be deserialized into a known receive type. + /// + public sealed class AutoSDKWebSocketUnknownMessageEventArgs : global::System.EventArgs + { + /// + /// Initializes a new instance of the class. + /// + public AutoSDKWebSocketUnknownMessageEventArgs( + string rawText, + global::System.Text.Json.JsonElement? json) + { + RawText = rawText ?? string.Empty; + Json = json; + } + + /// + /// Gets the raw text received from the WebSocket. + /// + public string RawText { get; } + + /// + /// Gets the parsed JSON payload when available. + /// + public global::System.Text.Json.JsonElement? Json { get; } + } + + /// + /// Gets the current WebSocket connection status. + /// + public AutoSDKWebSocketConnectionStatus Status { get; private set; } = AutoSDKWebSocketConnectionStatus.Disconnected; + + /// + /// Gets reconnect options used by the receive loop. + /// + public AutoSDKWebSocketReconnectOptions ReconnectOptions { get; } = new AutoSDKWebSocketReconnectOptions(); + + /// + /// Raised after the WebSocket connection is opened. + /// + public event global::System.EventHandler? Connected; + + /// + /// Raised after the WebSocket connection is closed. + /// + public event global::System.EventHandler? Closed; + + /// + /// Raised after a WebSocket connection exception is observed. + /// + public event global::System.EventHandler? ExceptionOccurred; + + /// + /// Raised before a reconnect attempt starts. + /// + public event global::System.EventHandler? Reconnecting; + + /// + /// Raised when an inbound text message cannot be deserialized into a known receive event. + /// + public event global::System.EventHandler? UnknownMessage; /// /// @@ -44,6 +289,142 @@ public SimliLivekitRealtimeClient( + private void RememberConnectionOptions( + global::System.Uri uri, + global::System.Collections.Generic.IDictionary? additionalHeaders, + global::System.Collections.Generic.IEnumerable? additionalSubProtocols, + global::System.TimeSpan? keepAliveInterval, + global::System.TimeSpan? connectTimeout) + { + _lastConnectUri = uri; + _lastAdditionalHeaders = additionalHeaders is null + ? null + : new global::System.Collections.Generic.Dictionary( + additionalHeaders, + global::System.StringComparer.OrdinalIgnoreCase); + _lastAdditionalSubProtocols = additionalSubProtocols is null + ? null + : new global::System.Collections.Generic.List(additionalSubProtocols); + _lastKeepAliveInterval = keepAliveInterval; + _lastConnectTimeout = connectTimeout; + } + + private void ResetClientWebSocket() + { + _clientWebSocket.Dispose(); + _clientWebSocket = new global::System.Net.WebSockets.ClientWebSocket(); + Initialized(_clientWebSocket); + } + + private void RaiseClosed( + global::System.Net.WebSockets.WebSocketCloseStatus? closeStatus, + string? closeStatusDescription) + { + Status = AutoSDKWebSocketConnectionStatus.Closed; + Closed?.Invoke( + this, + new AutoSDKWebSocketClosedEventArgs(closeStatus, closeStatusDescription)); + } + + private void RaiseException( + global::System.Exception exception) + { + Status = AutoSDKWebSocketConnectionStatus.Faulted; + ExceptionOccurred?.Invoke( + this, + new AutoSDKWebSocketExceptionEventArgs(exception)); + } + + private global::System.TimeSpan GetReconnectDelay( + int attempt) + { + var delay = ReconnectOptions.InitialDelay; + if (delay < global::System.TimeSpan.Zero) + { + delay = global::System.TimeSpan.Zero; + } + + var multiplier = ReconnectOptions.BackoffMultiplier; + if (multiplier < 1D) + { + multiplier = 1D; + } + + for (var index = 1; index < attempt; index++) + { + var nextMilliseconds = delay.TotalMilliseconds * multiplier; + if (nextMilliseconds >= ReconnectOptions.MaxDelay.TotalMilliseconds) + { + delay = ReconnectOptions.MaxDelay; + break; + } + + delay = global::System.TimeSpan.FromMilliseconds(nextMilliseconds); + } + + if (ReconnectOptions.MaxDelay >= global::System.TimeSpan.Zero && + delay > ReconnectOptions.MaxDelay) + { + delay = ReconnectOptions.MaxDelay; + } + + return delay; + } + + private async global::System.Threading.Tasks.Task TryReconnectAsync( + global::System.Exception exception, + global::System.Threading.CancellationToken cancellationToken) + { + if (!ReconnectOptions.Enabled || + _lastConnectUri is null || + cancellationToken.IsCancellationRequested) + { + return false; + } + + var maxAttempts = ReconnectOptions.MaxAttempts < 1 ? 1 : ReconnectOptions.MaxAttempts; + var lastException = exception; + for (var attempt = 1; attempt <= maxAttempts; attempt++) + { + var delay = GetReconnectDelay(attempt); + Reconnecting?.Invoke( + this, + new AutoSDKWebSocketReconnectEventArgs(attempt, delay, lastException)); + + if (delay > global::System.TimeSpan.Zero) + { + await global::System.Threading.Tasks.Task.Delay(delay, cancellationToken).ConfigureAwait(false); + } + + try + { + ResetClientWebSocket(); + await ConnectAsync( + uri: _lastConnectUri, + additionalHeaders: _lastAdditionalHeaders, + additionalSubProtocols: _lastAdditionalSubProtocols, + keepAliveInterval: _lastKeepAliveInterval, + connectTimeout: _lastConnectTimeout, + cancellationToken: cancellationToken).ConfigureAwait(false); + return true; + } + catch (global::System.Exception reconnectException) when ( + reconnectException is global::System.Net.WebSockets.WebSocketException || + reconnectException is global::System.Net.Http.HttpRequestException || + reconnectException is global::System.OperationCanceledException) + { + lastException = reconnectException; + RaiseException(reconnectException); + if (cancellationToken.IsCancellationRequested) + { + return false; + } + } + } + + return false; + } + private void ApplyConnectionOptions( global::System.Collections.Generic.IDictionary? additionalHeaders, global::System.Collections.Generic.IEnumerable? additionalSubProtocols, @@ -89,7 +470,18 @@ private void ApplyConnectionOptions( try { + Status = AutoSDKWebSocketConnectionStatus.Connecting; await _clientWebSocket.ConnectAsync(uri, __effectiveCancellationToken).ConfigureAwait(false); + Status = AutoSDKWebSocketConnectionStatus.Connected; + Connected?.Invoke(this, global::System.EventArgs.Empty); + } + catch (global::System.Exception exception) when ( + exception is global::System.Net.WebSockets.WebSocketException || + exception is global::System.Net.Http.HttpRequestException || + exception is global::System.OperationCanceledException) + { + RaiseException(exception); + throw; } finally { @@ -122,6 +514,7 @@ private void ApplyConnectionOptions( __uri = new global::System.Uri(__pathBuilder.ToString()); } + RememberConnectionOptions(__uri, additionalHeaders, additionalSubProtocols, keepAliveInterval, connectTimeout); ApplyConnectionOptions(additionalHeaders, additionalSubProtocols, keepAliveInterval); await ConnectAsyncCore(__uri, connectTimeout, cancellationToken).ConfigureAwait(false); } @@ -162,6 +555,7 @@ private void ApplyConnectionOptions( __uri = new global::System.Uri(__pathBuilder.ToString()); } + RememberConnectionOptions(__uri, additionalHeaders, additionalSubProtocols, keepAliveInterval, connectTimeout); ApplyConnectionOptions(additionalHeaders, additionalSubProtocols, keepAliveInterval); await ConnectAsyncCore(__uri, connectTimeout, cancellationToken).ConfigureAwait(false); } diff --git a/src/libs/Simli/Generated/Simli.Realtime.SimliPeerToPeerRealtimeClient.g.cs b/src/libs/Simli/Generated/Simli.Realtime.SimliPeerToPeerRealtimeClient.g.cs index 2b4de4d..0ad7f40 100644 --- a/src/libs/Simli/Generated/Simli.Realtime.SimliPeerToPeerRealtimeClient.g.cs +++ b/src/libs/Simli/Generated/Simli.Realtime.SimliPeerToPeerRealtimeClient.g.cs @@ -13,7 +13,252 @@ public sealed partial class SimliPeerToPeerRealtimeClient : global::System.IDisp /// public const string DefaultBaseUrl = "wss://api.simli.ai/compose/webrtc/p2p"; - private readonly global::System.Net.WebSockets.ClientWebSocket _clientWebSocket; + private global::System.Net.WebSockets.ClientWebSocket _clientWebSocket; + private global::System.Uri? _lastConnectUri; + private global::System.Collections.Generic.Dictionary? _lastAdditionalHeaders; + private global::System.Collections.Generic.List? _lastAdditionalSubProtocols; + private global::System.TimeSpan? _lastKeepAliveInterval; + private global::System.TimeSpan? _lastConnectTimeout; + + + /// + /// Current WebSocket connection status. + /// + public enum AutoSDKWebSocketConnectionStatus + { + /// + /// The client is not connected. + /// + Disconnected, + + /// + /// The client is connecting. + /// + Connecting, + + /// + /// The client is connected. + /// + Connected, + + /// + /// The client observed a normal close. + /// + Closed, + + /// + /// The client observed a connection error. + /// + Faulted, + } + + /// + /// Configures automatic reconnect attempts after receive-loop WebSocket failures. + /// + public sealed class AutoSDKWebSocketReconnectOptions + { + /// + /// Enables reconnect attempts from the receive loop. + /// + public bool Enabled { get; set; } + + /// + /// Maximum reconnect attempts per observed receive failure. + /// + public int MaxAttempts { get; set; } = 3; + + /// + /// Delay before the first reconnect attempt. + /// + public global::System.TimeSpan InitialDelay { get; set; } = global::System.TimeSpan.FromSeconds(1); + + /// + /// Maximum delay between reconnect attempts. + /// + public global::System.TimeSpan MaxDelay { get; set; } = global::System.TimeSpan.FromSeconds(30); + + /// + /// Multiplier applied to the delay after each failed reconnect attempt. + /// + public double BackoffMultiplier { get; set; } = 2D; + } + + /// + /// Event data for closed WebSocket connections. + /// + public sealed class AutoSDKWebSocketClosedEventArgs : global::System.EventArgs + { + /// + /// Initializes a new instance of the class. + /// + public AutoSDKWebSocketClosedEventArgs( + global::System.Net.WebSockets.WebSocketCloseStatus? closeStatus, + string? closeStatusDescription) + { + CloseStatus = closeStatus; + CloseStatusDescription = closeStatusDescription; + } + + /// + /// Gets the WebSocket close status. + /// + public global::System.Net.WebSockets.WebSocketCloseStatus? CloseStatus { get; } + + /// + /// Gets the WebSocket close status description. + /// + public string? CloseStatusDescription { get; } + } + + /// + /// Event data for WebSocket exceptions. + /// + public sealed class AutoSDKWebSocketExceptionEventArgs : global::System.EventArgs + { + /// + /// Initializes a new instance of the class. + /// + public AutoSDKWebSocketExceptionEventArgs( + global::System.Exception exception) + { + Exception = exception ?? throw new global::System.ArgumentNullException(nameof(exception)); + } + + /// + /// Gets the observed exception. + /// + public global::System.Exception Exception { get; } + } + + /// + /// Event data for WebSocket reconnect attempts. + /// + public sealed class AutoSDKWebSocketReconnectEventArgs : global::System.EventArgs + { + /// + /// Initializes a new instance of the class. + /// + public AutoSDKWebSocketReconnectEventArgs( + int attempt, + global::System.TimeSpan delay, + global::System.Exception exception) + { + Attempt = attempt; + Delay = delay; + Exception = exception ?? throw new global::System.ArgumentNullException(nameof(exception)); + } + + /// + /// Gets the reconnect attempt number. + /// + public int Attempt { get; } + + /// + /// Gets the delay before the reconnect attempt. + /// + public global::System.TimeSpan Delay { get; } + + /// + /// Gets the exception that triggered reconnect. + /// + public global::System.Exception Exception { get; } + } + + /// + /// Event data for deserialized WebSocket messages. + /// + public sealed class AutoSDKWebSocketMessageEventArgs : global::System.EventArgs + { + /// + /// Initializes a new instance of the class. + /// + public AutoSDKWebSocketMessageEventArgs( + TMessage message, + string rawText, + global::System.Text.Json.JsonElement? json) + { + Message = message; + RawText = rawText ?? string.Empty; + Json = json; + } + + /// + /// Gets the deserialized message. + /// + public TMessage Message { get; } + + /// + /// Gets the raw text received from the WebSocket. + /// + public string RawText { get; } + + /// + /// Gets the parsed JSON payload when available. + /// + public global::System.Text.Json.JsonElement? Json { get; } + } + + /// + /// Event data for messages that could not be deserialized into a known receive type. + /// + public sealed class AutoSDKWebSocketUnknownMessageEventArgs : global::System.EventArgs + { + /// + /// Initializes a new instance of the class. + /// + public AutoSDKWebSocketUnknownMessageEventArgs( + string rawText, + global::System.Text.Json.JsonElement? json) + { + RawText = rawText ?? string.Empty; + Json = json; + } + + /// + /// Gets the raw text received from the WebSocket. + /// + public string RawText { get; } + + /// + /// Gets the parsed JSON payload when available. + /// + public global::System.Text.Json.JsonElement? Json { get; } + } + + /// + /// Gets the current WebSocket connection status. + /// + public AutoSDKWebSocketConnectionStatus Status { get; private set; } = AutoSDKWebSocketConnectionStatus.Disconnected; + + /// + /// Gets reconnect options used by the receive loop. + /// + public AutoSDKWebSocketReconnectOptions ReconnectOptions { get; } = new AutoSDKWebSocketReconnectOptions(); + + /// + /// Raised after the WebSocket connection is opened. + /// + public event global::System.EventHandler? Connected; + + /// + /// Raised after the WebSocket connection is closed. + /// + public event global::System.EventHandler? Closed; + + /// + /// Raised after a WebSocket connection exception is observed. + /// + public event global::System.EventHandler? ExceptionOccurred; + + /// + /// Raised before a reconnect attempt starts. + /// + public event global::System.EventHandler? Reconnecting; + + /// + /// Raised when an inbound text message cannot be deserialized into a known receive event. + /// + public event global::System.EventHandler? UnknownMessage; /// /// @@ -44,6 +289,142 @@ public SimliPeerToPeerRealtimeClient( + private void RememberConnectionOptions( + global::System.Uri uri, + global::System.Collections.Generic.IDictionary? additionalHeaders, + global::System.Collections.Generic.IEnumerable? additionalSubProtocols, + global::System.TimeSpan? keepAliveInterval, + global::System.TimeSpan? connectTimeout) + { + _lastConnectUri = uri; + _lastAdditionalHeaders = additionalHeaders is null + ? null + : new global::System.Collections.Generic.Dictionary( + additionalHeaders, + global::System.StringComparer.OrdinalIgnoreCase); + _lastAdditionalSubProtocols = additionalSubProtocols is null + ? null + : new global::System.Collections.Generic.List(additionalSubProtocols); + _lastKeepAliveInterval = keepAliveInterval; + _lastConnectTimeout = connectTimeout; + } + + private void ResetClientWebSocket() + { + _clientWebSocket.Dispose(); + _clientWebSocket = new global::System.Net.WebSockets.ClientWebSocket(); + Initialized(_clientWebSocket); + } + + private void RaiseClosed( + global::System.Net.WebSockets.WebSocketCloseStatus? closeStatus, + string? closeStatusDescription) + { + Status = AutoSDKWebSocketConnectionStatus.Closed; + Closed?.Invoke( + this, + new AutoSDKWebSocketClosedEventArgs(closeStatus, closeStatusDescription)); + } + + private void RaiseException( + global::System.Exception exception) + { + Status = AutoSDKWebSocketConnectionStatus.Faulted; + ExceptionOccurred?.Invoke( + this, + new AutoSDKWebSocketExceptionEventArgs(exception)); + } + + private global::System.TimeSpan GetReconnectDelay( + int attempt) + { + var delay = ReconnectOptions.InitialDelay; + if (delay < global::System.TimeSpan.Zero) + { + delay = global::System.TimeSpan.Zero; + } + + var multiplier = ReconnectOptions.BackoffMultiplier; + if (multiplier < 1D) + { + multiplier = 1D; + } + + for (var index = 1; index < attempt; index++) + { + var nextMilliseconds = delay.TotalMilliseconds * multiplier; + if (nextMilliseconds >= ReconnectOptions.MaxDelay.TotalMilliseconds) + { + delay = ReconnectOptions.MaxDelay; + break; + } + + delay = global::System.TimeSpan.FromMilliseconds(nextMilliseconds); + } + + if (ReconnectOptions.MaxDelay >= global::System.TimeSpan.Zero && + delay > ReconnectOptions.MaxDelay) + { + delay = ReconnectOptions.MaxDelay; + } + + return delay; + } + + private async global::System.Threading.Tasks.Task TryReconnectAsync( + global::System.Exception exception, + global::System.Threading.CancellationToken cancellationToken) + { + if (!ReconnectOptions.Enabled || + _lastConnectUri is null || + cancellationToken.IsCancellationRequested) + { + return false; + } + + var maxAttempts = ReconnectOptions.MaxAttempts < 1 ? 1 : ReconnectOptions.MaxAttempts; + var lastException = exception; + for (var attempt = 1; attempt <= maxAttempts; attempt++) + { + var delay = GetReconnectDelay(attempt); + Reconnecting?.Invoke( + this, + new AutoSDKWebSocketReconnectEventArgs(attempt, delay, lastException)); + + if (delay > global::System.TimeSpan.Zero) + { + await global::System.Threading.Tasks.Task.Delay(delay, cancellationToken).ConfigureAwait(false); + } + + try + { + ResetClientWebSocket(); + await ConnectAsync( + uri: _lastConnectUri, + additionalHeaders: _lastAdditionalHeaders, + additionalSubProtocols: _lastAdditionalSubProtocols, + keepAliveInterval: _lastKeepAliveInterval, + connectTimeout: _lastConnectTimeout, + cancellationToken: cancellationToken).ConfigureAwait(false); + return true; + } + catch (global::System.Exception reconnectException) when ( + reconnectException is global::System.Net.WebSockets.WebSocketException || + reconnectException is global::System.Net.Http.HttpRequestException || + reconnectException is global::System.OperationCanceledException) + { + lastException = reconnectException; + RaiseException(reconnectException); + if (cancellationToken.IsCancellationRequested) + { + return false; + } + } + } + + return false; + } + private void ApplyConnectionOptions( global::System.Collections.Generic.IDictionary? additionalHeaders, global::System.Collections.Generic.IEnumerable? additionalSubProtocols, @@ -89,7 +470,18 @@ private void ApplyConnectionOptions( try { + Status = AutoSDKWebSocketConnectionStatus.Connecting; await _clientWebSocket.ConnectAsync(uri, __effectiveCancellationToken).ConfigureAwait(false); + Status = AutoSDKWebSocketConnectionStatus.Connected; + Connected?.Invoke(this, global::System.EventArgs.Empty); + } + catch (global::System.Exception exception) when ( + exception is global::System.Net.WebSockets.WebSocketException || + exception is global::System.Net.Http.HttpRequestException || + exception is global::System.OperationCanceledException) + { + RaiseException(exception); + throw; } finally { @@ -122,6 +514,7 @@ private void ApplyConnectionOptions( __uri = new global::System.Uri(__pathBuilder.ToString()); } + RememberConnectionOptions(__uri, additionalHeaders, additionalSubProtocols, keepAliveInterval, connectTimeout); ApplyConnectionOptions(additionalHeaders, additionalSubProtocols, keepAliveInterval); await ConnectAsyncCore(__uri, connectTimeout, cancellationToken).ConfigureAwait(false); } @@ -162,6 +555,7 @@ private void ApplyConnectionOptions( __uri = new global::System.Uri(__pathBuilder.ToString()); } + RememberConnectionOptions(__uri, additionalHeaders, additionalSubProtocols, keepAliveInterval, connectTimeout); ApplyConnectionOptions(additionalHeaders, additionalSubProtocols, keepAliveInterval); await ConnectAsyncCore(__uri, connectTimeout, cancellationToken).ConfigureAwait(false); } diff --git a/src/libs/Simli/Generated/Simli.SimliClient.AudioToVideoInterfaceStaticAudioPost.g.cs b/src/libs/Simli/Generated/Simli.SimliClient.AudioToVideoInterfaceStaticAudioPost.g.cs index c3d39c1..f4ea51e 100644 --- a/src/libs/Simli/Generated/Simli.SimliClient.AudioToVideoInterfaceStaticAudioPost.g.cs +++ b/src/libs/Simli/Generated/Simli.SimliClient.AudioToVideoInterfaceStaticAudioPost.g.cs @@ -51,6 +51,29 @@ partial void ProcessAudioToVideoInterfaceStaticAudioPostResponseContent( /// public async global::System.Threading.Tasks.Task AudioToVideoInterfaceStaticAudioPostAsync( + global::Simli.AudioToVideoRequest request, + global::Simli.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await AudioToVideoInterfaceStaticAudioPostAsResponseAsync( + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Generate Static Video
+ /// Generate and stream a static video file from a given audio sample + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> AudioToVideoInterfaceStaticAudioPostAsResponseAsync( + global::Simli.AudioToVideoRequest request, global::Simli.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) @@ -85,6 +108,7 @@ partial void ProcessAudioToVideoInterfaceStaticAudioPostResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Simli.PathBuilder( path: "/static/audio", baseUri: HttpClient.BaseAddress); @@ -164,6 +188,8 @@ partial void ProcessAudioToVideoInterfaceStaticAudioPostResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -174,6 +200,11 @@ partial void ProcessAudioToVideoInterfaceStaticAudioPostResponseContent( } 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, @@ -191,6 +222,8 @@ partial void ProcessAudioToVideoInterfaceStaticAudioPostResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -200,8 +233,7 @@ partial void ProcessAudioToVideoInterfaceStaticAudioPostResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Simli.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -210,6 +242,11 @@ partial void ProcessAudioToVideoInterfaceStaticAudioPostResponseContent( __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( @@ -226,14 +263,15 @@ partial void ProcessAudioToVideoInterfaceStaticAudioPostResponseContent( 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( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -273,6 +311,8 @@ partial void ProcessAudioToVideoInterfaceStaticAudioPostResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -293,6 +333,8 @@ partial void ProcessAudioToVideoInterfaceStaticAudioPostResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Validation Error @@ -355,9 +397,13 @@ partial void ProcessAudioToVideoInterfaceStaticAudioPostResponseContent( { __response.EnsureSuccessStatusCode(); - return - global::Simli.AudioToVideoInterfaceStaticAudioPostResponse.FromJson(__content, JsonSerializerContext) ?? + var __value = global::Simli.AudioToVideoInterfaceStaticAudioPostResponse.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Simli.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Simli.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -385,9 +431,13 @@ partial void ProcessAudioToVideoInterfaceStaticAudioPostResponseContent( #endif ).ConfigureAwait(false); - return - await global::Simli.AudioToVideoInterfaceStaticAudioPostResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::Simli.AudioToVideoInterfaceStaticAudioPostResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Simli.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Simli.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { diff --git a/src/libs/Simli/Generated/Simli.SimliClient.DeleteFacesTrinityById.g.cs b/src/libs/Simli/Generated/Simli.SimliClient.DeleteFacesTrinityById.g.cs index b8d6da8..16ecec7 100644 --- a/src/libs/Simli/Generated/Simli.SimliClient.DeleteFacesTrinityById.g.cs +++ b/src/libs/Simli/Generated/Simli.SimliClient.DeleteFacesTrinityById.g.cs @@ -48,6 +48,25 @@ partial void ProcessDeleteFacesTrinityByIdResponse( global::System.Guid id, global::Simli.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) + { + await DeleteFacesTrinityByIdAsResponseAsync( + id: id, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + } + /// + /// Delete a face
+ /// Removes a face. This can not be undone. All agents connected to this face_id will be broken + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task DeleteFacesTrinityByIdAsResponseAsync( + global::System.Guid id, + global::Simli.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( client: HttpClient); @@ -77,6 +96,7 @@ partial void ProcessDeleteFacesTrinityByIdResponse( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Simli.PathBuilder( path: $"/faces/trinity/{id}", baseUri: HttpClient.BaseAddress); @@ -150,6 +170,8 @@ partial void ProcessDeleteFacesTrinityByIdResponse( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -160,6 +182,11 @@ partial void ProcessDeleteFacesTrinityByIdResponse( } 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, @@ -177,6 +204,8 @@ partial void ProcessDeleteFacesTrinityByIdResponse( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -186,8 +215,7 @@ partial void ProcessDeleteFacesTrinityByIdResponse( __httpRequest.Dispose(); __httpRequest = null; await global::Simli.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -196,6 +224,11 @@ partial void ProcessDeleteFacesTrinityByIdResponse( __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( @@ -212,14 +245,15 @@ partial void ProcessDeleteFacesTrinityByIdResponse( 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( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -259,6 +293,8 @@ partial void ProcessDeleteFacesTrinityByIdResponse( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -279,6 +315,8 @@ partial void ProcessDeleteFacesTrinityByIdResponse( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // @@ -365,6 +403,10 @@ partial void ProcessDeleteFacesTrinityByIdResponse( { __response.EnsureSuccessStatusCode(); + return new global::Simli.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Simli.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri); } catch (global::System.Exception __ex) { @@ -386,6 +428,10 @@ partial void ProcessDeleteFacesTrinityByIdResponse( try { __response.EnsureSuccessStatusCode(); + return new global::Simli.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Simli.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri); } catch (global::System.Exception __ex) { diff --git a/src/libs/Simli/Generated/Simli.SimliClient.EnqueueGSAGenerationFacesGsCreatePost.g.cs b/src/libs/Simli/Generated/Simli.SimliClient.EnqueueGSAGenerationFacesGsCreatePost.g.cs index 8a69aff..2a984bf 100644 --- a/src/libs/Simli/Generated/Simli.SimliClient.EnqueueGSAGenerationFacesGsCreatePost.g.cs +++ b/src/libs/Simli/Generated/Simli.SimliClient.EnqueueGSAGenerationFacesGsCreatePost.g.cs @@ -60,6 +60,38 @@ partial void ProcessEnqueueGSAGenerationFacesGsCreatePostResponseContent( /// public async global::System.Threading.Tasks.Task EnqueueGSAGenerationFacesGsCreatePostAsync( + global::Simli.BodyEnqueueGSAGenerationFacesGsCreatePost request, + global::Simli.TrinityVersion? gsVersion = default, + string? faceName = default, + global::Simli.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await EnqueueGSAGenerationFacesGsCreatePostAsResponseAsync( + + request: request, + gsVersion: gsVersion, + faceName: faceName, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Generate Trinity Face + /// + /// + /// Default Value: GSA_1.0 + /// + /// + /// Default Value: untitled_avatar + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> EnqueueGSAGenerationFacesGsCreatePostAsResponseAsync( + global::Simli.BodyEnqueueGSAGenerationFacesGsCreatePost request, global::Simli.TrinityVersion? gsVersion = default, string? faceName = default, @@ -94,16 +126,17 @@ partial void ProcessEnqueueGSAGenerationFacesGsCreatePostResponseContent( var __maxAttempts = global::Simli.AutoSDKRequestOptionsSupport.GetMaxAttempts( clientOptions: Options, requestOptions: requestOptions, - supportsRetry: true); + supportsRetry: false); global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Simli.PathBuilder( path: "/faces/trinity", - baseUri: HttpClient.BaseAddress); + baseUri: HttpClient.BaseAddress); __pathBuilder .AddOptionalParameter("gsVersion", gsVersion?.ToString()) - .AddOptionalParameter("face_name", faceName) + .AddOptionalParameter("face_name", faceName) ; var __path = __pathBuilder.ToString(); __path = global::Simli.AutoSDKRequestOptionsSupport.AppendQueryParameters( @@ -134,6 +167,7 @@ partial void ProcessEnqueueGSAGenerationFacesGsCreatePostResponseContent( __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); } } + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); if (gsVersion != default) { @@ -141,13 +175,15 @@ partial void ProcessEnqueueGSAGenerationFacesGsCreatePostResponseContent( __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( @@ -186,7 +222,9 @@ request.Imagename is null { __contentImage.Headers.ContentDisposition.FileNameStar = null; } + __httpRequest.Content = __httpRequestContent; + global::Simli.AutoSDKRequestOptionsSupport.ApplyHeaders( request: __httpRequest, clientHeaders: Options.Headers, @@ -230,6 +268,8 @@ request.Imagename is null attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -240,6 +280,11 @@ request.Imagename is null } 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, @@ -257,6 +302,8 @@ request.Imagename is null attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -266,8 +313,7 @@ request.Imagename is null __httpRequest.Dispose(); __httpRequest = null; await global::Simli.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -276,6 +322,11 @@ request.Imagename is 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( @@ -292,14 +343,15 @@ request.Imagename is null 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( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -339,6 +391,8 @@ request.Imagename is null attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -359,6 +413,8 @@ request.Imagename is null attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Validation Error @@ -421,7 +477,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) { @@ -449,7 +509,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) { @@ -522,5 +586,962 @@ request.Imagename is null requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } + + /// + /// Generate Trinity Face + /// + /// + /// Default Value: GSA_1.0 + /// + /// + /// Default Value: untitled_avatar + /// + /// + /// The stream to send as the multipart 'image' file part. + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task EnqueueGSAGenerationFacesGsCreatePostAsync( + global::System.IO.Stream image, + string imagename, + global::Simli.TrinityVersion? gsVersion = default, + string? faceName = 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.BodyEnqueueGSAGenerationFacesGsCreatePost + { + Image = global::System.Array.Empty(), + Imagename = imagename, + }; + PrepareArguments( + client: HttpClient); + PrepareEnqueueGSAGenerationFacesGsCreatePostArguments( + httpClient: HttpClient, + gsVersion: ref gsVersion, + faceName: ref faceName, + request: request); + + + var __authorizations = global::Simli.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_EnqueueGSAGenerationFacesGsCreatePostSecurityRequirements, + operationName: "EnqueueGSAGenerationFacesGsCreatePostAsync"); + + 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", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("gsVersion", gsVersion?.ToString()) + .AddOptionalParameter("face_name", faceName) + ; + 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(); + 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 + ? "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); + PrepareEnqueueGSAGenerationFacesGsCreatePostRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + gsVersion: gsVersion, + faceName: faceName, + 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: "EnqueueGSAGenerationFacesGsCreatePost", + methodName: "EnqueueGSAGenerationFacesGsCreatePostAsync", + pathTemplate: "\"/faces/trinity\"", + httpMethod: "POST", + 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.ResponseContentRead, + 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: "EnqueueGSAGenerationFacesGsCreatePost", + methodName: "EnqueueGSAGenerationFacesGsCreatePostAsync", + pathTemplate: "\"/faces/trinity\"", + httpMethod: "POST", + 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: "EnqueueGSAGenerationFacesGsCreatePost", + methodName: "EnqueueGSAGenerationFacesGsCreatePostAsync", + pathTemplate: "\"/faces/trinity\"", + httpMethod: "POST", + 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."); + } + + using (__response) + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessEnqueueGSAGenerationFacesGsCreatePostResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Simli.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Simli.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "EnqueueGSAGenerationFacesGsCreatePost", + methodName: "EnqueueGSAGenerationFacesGsCreatePostAsync", + pathTemplate: "\"/faces/trinity\"", + httpMethod: "POST", + 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: "EnqueueGSAGenerationFacesGsCreatePost", + methodName: "EnqueueGSAGenerationFacesGsCreatePostAsync", + pathTemplate: "\"/faces/trinity\"", + httpMethod: "POST", + 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); + } + // 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 new global::Simli.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessEnqueueGSAGenerationFacesGsCreatePostResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return __content; + } + catch (global::System.Exception __ex) + { + throw new global::Simli.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return __content; + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Simli.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + + } + } + finally + { + __httpRequest?.Dispose(); + } + } + /// + /// Generate Trinity Face + /// + /// + /// Default Value: GSA_1.0 + /// + /// + /// Default Value: untitled_avatar + /// + /// + /// The stream to send as the multipart 'image' file part. + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> EnqueueGSAGenerationFacesGsCreatePostAsResponseAsync( + global::System.IO.Stream image, + string imagename, + global::Simli.TrinityVersion? gsVersion = default, + string? faceName = 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.BodyEnqueueGSAGenerationFacesGsCreatePost + { + Image = global::System.Array.Empty(), + Imagename = imagename, + }; + PrepareArguments( + client: HttpClient); + PrepareEnqueueGSAGenerationFacesGsCreatePostArguments( + httpClient: HttpClient, + gsVersion: ref gsVersion, + faceName: ref faceName, + request: request); + + + var __authorizations = global::Simli.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_EnqueueGSAGenerationFacesGsCreatePostSecurityRequirements, + operationName: "EnqueueGSAGenerationFacesGsCreatePostAsync"); + + 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", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("gsVersion", gsVersion?.ToString()) + .AddOptionalParameter("face_name", faceName) + ; + 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(); + 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 + ? "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); + PrepareEnqueueGSAGenerationFacesGsCreatePostRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + gsVersion: gsVersion, + faceName: faceName, + 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: "EnqueueGSAGenerationFacesGsCreatePost", + methodName: "EnqueueGSAGenerationFacesGsCreatePostAsync", + pathTemplate: "\"/faces/trinity\"", + httpMethod: "POST", + 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.ResponseContentRead, + 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: "EnqueueGSAGenerationFacesGsCreatePost", + methodName: "EnqueueGSAGenerationFacesGsCreatePostAsync", + pathTemplate: "\"/faces/trinity\"", + httpMethod: "POST", + 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: "EnqueueGSAGenerationFacesGsCreatePost", + methodName: "EnqueueGSAGenerationFacesGsCreatePostAsync", + pathTemplate: "\"/faces/trinity\"", + httpMethod: "POST", + 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."); + } + + using (__response) + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessEnqueueGSAGenerationFacesGsCreatePostResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Simli.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Simli.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "EnqueueGSAGenerationFacesGsCreatePost", + methodName: "EnqueueGSAGenerationFacesGsCreatePostAsync", + pathTemplate: "\"/faces/trinity\"", + httpMethod: "POST", + 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: "EnqueueGSAGenerationFacesGsCreatePost", + methodName: "EnqueueGSAGenerationFacesGsCreatePostAsync", + pathTemplate: "\"/faces/trinity\"", + httpMethod: "POST", + 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); + } + // 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 new global::Simli.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessEnqueueGSAGenerationFacesGsCreatePostResponseContent( + 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 new global::Simli.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return new global::Simli.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Simli.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __content); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Simli.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + + } + } + finally + { + __httpRequest?.Dispose(); + } + } } } \ No newline at end of file diff --git a/src/libs/Simli/Generated/Simli.SimliClient.GetCachedVideoMp4StaticMp4MachineIPFileGet.g.cs b/src/libs/Simli/Generated/Simli.SimliClient.GetCachedVideoMp4StaticMp4MachineIPFileGet.g.cs index 1dc140d..b1ccfa1 100644 --- a/src/libs/Simli/Generated/Simli.SimliClient.GetCachedVideoMp4StaticMp4MachineIPFileGet.g.cs +++ b/src/libs/Simli/Generated/Simli.SimliClient.GetCachedVideoMp4StaticMp4MachineIPFileGet.g.cs @@ -56,6 +56,29 @@ partial void ProcessGetCachedVideoMp4StaticMp4MachineIPFileGetResponseContent( string file, global::Simli.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await GetCachedVideoMp4StaticMp4MachineIPFileGetAsResponseAsync( + destination: destination, + file: file, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// 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, + global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( client: HttpClient); @@ -86,6 +109,7 @@ partial void ProcessGetCachedVideoMp4StaticMp4MachineIPFileGetResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Simli.PathBuilder( path: $"/static/mp4/{destination}/{file}", baseUri: HttpClient.BaseAddress); @@ -160,6 +184,8 @@ partial void ProcessGetCachedVideoMp4StaticMp4MachineIPFileGetResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -170,6 +196,11 @@ partial void ProcessGetCachedVideoMp4StaticMp4MachineIPFileGetResponseContent( } 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, @@ -187,6 +218,8 @@ partial void ProcessGetCachedVideoMp4StaticMp4MachineIPFileGetResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -196,8 +229,7 @@ partial void ProcessGetCachedVideoMp4StaticMp4MachineIPFileGetResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Simli.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -206,6 +238,11 @@ partial void ProcessGetCachedVideoMp4StaticMp4MachineIPFileGetResponseContent( __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( @@ -222,14 +259,15 @@ partial void ProcessGetCachedVideoMp4StaticMp4MachineIPFileGetResponseContent( 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( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -269,6 +307,8 @@ partial void ProcessGetCachedVideoMp4StaticMp4MachineIPFileGetResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -289,6 +329,8 @@ partial void ProcessGetCachedVideoMp4StaticMp4MachineIPFileGetResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // @@ -384,7 +426,11 @@ partial void ProcessGetCachedVideoMp4StaticMp4MachineIPFileGetResponseContent( { __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) { @@ -412,7 +458,11 @@ partial void ProcessGetCachedVideoMp4StaticMp4MachineIPFileGetResponseContent( #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) { diff --git a/src/libs/Simli/Generated/Simli.SimliClient.GetCachedVideoStaticHlsMachineIPFileGet.g.cs b/src/libs/Simli/Generated/Simli.SimliClient.GetCachedVideoStaticHlsMachineIPFileGet.g.cs index c0d0669..45bb48c 100644 --- a/src/libs/Simli/Generated/Simli.SimliClient.GetCachedVideoStaticHlsMachineIPFileGet.g.cs +++ b/src/libs/Simli/Generated/Simli.SimliClient.GetCachedVideoStaticHlsMachineIPFileGet.g.cs @@ -57,6 +57,30 @@ partial void ProcessGetCachedVideoStaticHlsMachineIPFileGetResponseContent( string file, global::Simli.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await GetCachedVideoStaticHlsMachineIPFileGetAsResponseAsync( + destination: destination, + file: file, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// 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, + global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( client: HttpClient); @@ -87,6 +111,7 @@ partial void ProcessGetCachedVideoStaticHlsMachineIPFileGetResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Simli.PathBuilder( path: $"/static/hls/{destination}/{file}", baseUri: HttpClient.BaseAddress); @@ -161,6 +186,8 @@ partial void ProcessGetCachedVideoStaticHlsMachineIPFileGetResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -171,6 +198,11 @@ partial void ProcessGetCachedVideoStaticHlsMachineIPFileGetResponseContent( } 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, @@ -188,6 +220,8 @@ partial void ProcessGetCachedVideoStaticHlsMachineIPFileGetResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -197,8 +231,7 @@ partial void ProcessGetCachedVideoStaticHlsMachineIPFileGetResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Simli.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -207,6 +240,11 @@ partial void ProcessGetCachedVideoStaticHlsMachineIPFileGetResponseContent( __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( @@ -223,14 +261,15 @@ partial void ProcessGetCachedVideoStaticHlsMachineIPFileGetResponseContent( 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( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -270,6 +309,8 @@ partial void ProcessGetCachedVideoStaticHlsMachineIPFileGetResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -290,6 +331,8 @@ partial void ProcessGetCachedVideoStaticHlsMachineIPFileGetResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // @@ -385,7 +428,11 @@ partial void ProcessGetCachedVideoStaticHlsMachineIPFileGetResponseContent( { __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) { @@ -413,7 +460,11 @@ partial void ProcessGetCachedVideoStaticHlsMachineIPFileGetResponseContent( #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) { diff --git a/src/libs/Simli/Generated/Simli.SimliClient.GetFaces.g.cs b/src/libs/Simli/Generated/Simli.SimliClient.GetFaces.g.cs index 1e6034f..89f44ff 100644 --- a/src/libs/Simli/Generated/Simli.SimliClient.GetFaces.g.cs +++ b/src/libs/Simli/Generated/Simli.SimliClient.GetFaces.g.cs @@ -48,6 +48,23 @@ partial void ProcessGetFacesResponseContent( public async global::System.Threading.Tasks.Task> GetFacesAsync( global::Simli.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await GetFacesAsResponseAsync( + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Get all faces + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task>> GetFacesAsResponseAsync( + global::Simli.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( client: HttpClient); @@ -76,6 +93,7 @@ partial void ProcessGetFacesResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Simli.PathBuilder( path: "/faces", baseUri: HttpClient.BaseAddress); @@ -148,6 +166,8 @@ partial void ProcessGetFacesResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -158,6 +178,11 @@ partial void ProcessGetFacesResponseContent( } 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, @@ -175,6 +200,8 @@ partial void ProcessGetFacesResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -184,8 +211,7 @@ partial void ProcessGetFacesResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Simli.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -194,6 +220,11 @@ partial void ProcessGetFacesResponseContent( __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( @@ -210,14 +241,15 @@ partial void ProcessGetFacesResponseContent( 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( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -257,6 +289,8 @@ partial void ProcessGetFacesResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -277,6 +311,8 @@ partial void ProcessGetFacesResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } @@ -301,9 +337,13 @@ partial void ProcessGetFacesResponseContent( { __response.EnsureSuccessStatusCode(); - return - (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? + var __value = (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Simli.AutoSDKHttpResponse>( + statusCode: __response.StatusCode, + headers: global::Simli.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -331,9 +371,13 @@ partial void ProcessGetFacesResponseContent( #endif ).ConfigureAwait(false); - return - (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ?? + var __value = (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Simli.AutoSDKHttpResponse>( + statusCode: __response.StatusCode, + headers: global::Simli.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { diff --git a/src/libs/Simli/Generated/Simli.SimliClient.GetHistorySessions.g.cs b/src/libs/Simli/Generated/Simli.SimliClient.GetHistorySessions.g.cs index 5b02a43..29dceb5 100644 --- a/src/libs/Simli/Generated/Simli.SimliClient.GetHistorySessions.g.cs +++ b/src/libs/Simli/Generated/Simli.SimliClient.GetHistorySessions.g.cs @@ -61,6 +61,34 @@ partial void ProcessGetHistorySessionsResponseContent( int? end = default, global::Simli.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await GetHistorySessionsAsResponseAsync( + start: start, + end: end, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Retrieve session history
+ /// Returns a list of session history records for the authenticated user + ///
+ /// + /// Example: 1745750387 + /// + /// + /// Example: 1745750408 + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> GetHistorySessionsAsResponseAsync( + int? start = default, + int? end = default, + global::Simli.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( client: HttpClient); @@ -91,12 +119,13 @@ partial void ProcessGetHistorySessionsResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Simli.PathBuilder( path: "/history/sessions", - baseUri: HttpClient.BaseAddress); + baseUri: HttpClient.BaseAddress); __pathBuilder .AddOptionalParameter("start", start?.ToString()) - .AddOptionalParameter("end", end?.ToString()) + .AddOptionalParameter("end", end?.ToString()) ; var __path = __pathBuilder.ToString(); __path = global::Simli.AutoSDKRequestOptionsSupport.AppendQueryParameters( @@ -169,6 +198,8 @@ partial void ProcessGetHistorySessionsResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -179,6 +210,11 @@ partial void ProcessGetHistorySessionsResponseContent( } 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, @@ -196,6 +232,8 @@ partial void ProcessGetHistorySessionsResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -205,8 +243,7 @@ partial void ProcessGetHistorySessionsResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Simli.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -215,6 +252,11 @@ partial void ProcessGetHistorySessionsResponseContent( __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( @@ -231,14 +273,15 @@ partial void ProcessGetHistorySessionsResponseContent( 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( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -278,6 +321,8 @@ partial void ProcessGetHistorySessionsResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -298,6 +343,8 @@ partial void ProcessGetHistorySessionsResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Unauthorized - Invalid API key @@ -398,9 +445,13 @@ partial void ProcessGetHistorySessionsResponseContent( { __response.EnsureSuccessStatusCode(); - return - global::Simli.GetHistorySessionsResponse.FromJson(__content, JsonSerializerContext) ?? + var __value = global::Simli.GetHistorySessionsResponse.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Simli.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Simli.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -428,9 +479,13 @@ partial void ProcessGetHistorySessionsResponseContent( #endif ).ConfigureAwait(false); - return - await global::Simli.GetHistorySessionsResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::Simli.GetHistorySessionsResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Simli.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Simli.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { diff --git a/src/libs/Simli/Generated/Simli.SimliClient.GetIceServersComposeIceGet.g.cs b/src/libs/Simli/Generated/Simli.SimliClient.GetIceServersComposeIceGet.g.cs index 57035ca..ed952b7 100644 --- a/src/libs/Simli/Generated/Simli.SimliClient.GetIceServersComposeIceGet.g.cs +++ b/src/libs/Simli/Generated/Simli.SimliClient.GetIceServersComposeIceGet.g.cs @@ -49,6 +49,24 @@ partial void ProcessGetIceServersComposeIceGetResponseContent( public async global::System.Threading.Tasks.Task> GetIceServersComposeIceGetAsync( global::Simli.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await GetIceServersComposeIceGetAsResponseAsync( + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Get Ice Servers
+ /// Create a new set of temporary ICE Server Credentials for WebRTC P2P session + ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task>> GetIceServersComposeIceGetAsResponseAsync( + global::Simli.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( client: HttpClient); @@ -77,6 +95,7 @@ partial void ProcessGetIceServersComposeIceGetResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Simli.PathBuilder( path: "/compose/ice", baseUri: HttpClient.BaseAddress); @@ -149,6 +168,8 @@ partial void ProcessGetIceServersComposeIceGetResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -159,6 +180,11 @@ partial void ProcessGetIceServersComposeIceGetResponseContent( } 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, @@ -176,6 +202,8 @@ partial void ProcessGetIceServersComposeIceGetResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -185,8 +213,7 @@ partial void ProcessGetIceServersComposeIceGetResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Simli.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -195,6 +222,11 @@ partial void ProcessGetIceServersComposeIceGetResponseContent( __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( @@ -211,14 +243,15 @@ partial void ProcessGetIceServersComposeIceGetResponseContent( 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( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -258,6 +291,8 @@ partial void ProcessGetIceServersComposeIceGetResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -278,6 +313,8 @@ partial void ProcessGetIceServersComposeIceGetResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Validation Error @@ -340,9 +377,13 @@ partial void ProcessGetIceServersComposeIceGetResponseContent( { __response.EnsureSuccessStatusCode(); - return - (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? + var __value = (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Simli.AutoSDKHttpResponse>( + statusCode: __response.StatusCode, + headers: global::Simli.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -370,9 +411,13 @@ partial void ProcessGetIceServersComposeIceGetResponseContent( #endif ).ConfigureAwait(false); - return - (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ?? + var __value = (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Simli.AutoSDKHttpResponse>( + statusCode: __response.StatusCode, + headers: global::Simli.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { diff --git a/src/libs/Simli/Generated/Simli.SimliClient.GetRatelimiterSessions.g.cs b/src/libs/Simli/Generated/Simli.SimliClient.GetRatelimiterSessions.g.cs index 473f2d6..5221107 100644 --- a/src/libs/Simli/Generated/Simli.SimliClient.GetRatelimiterSessions.g.cs +++ b/src/libs/Simli/Generated/Simli.SimliClient.GetRatelimiterSessions.g.cs @@ -48,6 +48,23 @@ partial void ProcessGetRatelimiterSessionsResponseContent( public async global::System.Threading.Tasks.Task GetRatelimiterSessionsAsync( global::Simli.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await GetRatelimiterSessionsAsResponseAsync( + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Active Session Count + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> GetRatelimiterSessionsAsResponseAsync( + global::Simli.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( client: HttpClient); @@ -76,6 +93,7 @@ partial void ProcessGetRatelimiterSessionsResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Simli.PathBuilder( path: "/ratelimiter/sessions", baseUri: HttpClient.BaseAddress); @@ -148,6 +166,8 @@ partial void ProcessGetRatelimiterSessionsResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -158,6 +178,11 @@ partial void ProcessGetRatelimiterSessionsResponseContent( } 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, @@ -175,6 +200,8 @@ partial void ProcessGetRatelimiterSessionsResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -184,8 +211,7 @@ partial void ProcessGetRatelimiterSessionsResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Simli.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -194,6 +220,11 @@ partial void ProcessGetRatelimiterSessionsResponseContent( __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( @@ -210,14 +241,15 @@ partial void ProcessGetRatelimiterSessionsResponseContent( 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( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -257,6 +289,8 @@ partial void ProcessGetRatelimiterSessionsResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -277,6 +311,8 @@ partial void ProcessGetRatelimiterSessionsResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Unauthorized - Invalid API key @@ -339,9 +375,13 @@ partial void ProcessGetRatelimiterSessionsResponseContent( { __response.EnsureSuccessStatusCode(); - return - global::Simli.GetRatelimiterSessionsResponse.FromJson(__content, JsonSerializerContext) ?? + var __value = global::Simli.GetRatelimiterSessionsResponse.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Simli.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Simli.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -369,9 +409,13 @@ partial void ProcessGetRatelimiterSessionsResponseContent( #endif ).ConfigureAwait(false); - return - await global::Simli.GetRatelimiterSessionsResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::Simli.GetRatelimiterSessionsResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Simli.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Simli.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { diff --git a/src/libs/Simli/Generated/Simli.SimliClient.GetRequestStatusFacesGsStatusGet.g.cs b/src/libs/Simli/Generated/Simli.SimliClient.GetRequestStatusFacesGsStatusGet.g.cs index 05d197b..f7dddf3 100644 --- a/src/libs/Simli/Generated/Simli.SimliClient.GetRequestStatusFacesGsStatusGet.g.cs +++ b/src/libs/Simli/Generated/Simli.SimliClient.GetRequestStatusFacesGsStatusGet.g.cs @@ -52,6 +52,26 @@ partial void ProcessGetRequestStatusFacesGsStatusGetResponseContent( string? faceId = default, global::Simli.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await GetRequestStatusFacesGsStatusGetAsResponseAsync( + faceId: faceId, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Check Trinity Generation Status + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> GetRequestStatusFacesGsStatusGetAsResponseAsync( + string? faceId = default, + global::Simli.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( client: HttpClient); @@ -81,11 +101,12 @@ partial void ProcessGetRequestStatusFacesGsStatusGetResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Simli.PathBuilder( path: "/faces/trinity/generation_status", - baseUri: HttpClient.BaseAddress); + baseUri: HttpClient.BaseAddress); __pathBuilder - .AddOptionalParameter("face_id", faceId) + .AddOptionalParameter("face_id", faceId) ; var __path = __pathBuilder.ToString(); __path = global::Simli.AutoSDKRequestOptionsSupport.AppendQueryParameters( @@ -157,6 +178,8 @@ partial void ProcessGetRequestStatusFacesGsStatusGetResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -167,6 +190,11 @@ partial void ProcessGetRequestStatusFacesGsStatusGetResponseContent( } 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, @@ -184,6 +212,8 @@ partial void ProcessGetRequestStatusFacesGsStatusGetResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -193,8 +223,7 @@ partial void ProcessGetRequestStatusFacesGsStatusGetResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Simli.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -203,6 +232,11 @@ partial void ProcessGetRequestStatusFacesGsStatusGetResponseContent( __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( @@ -219,14 +253,15 @@ partial void ProcessGetRequestStatusFacesGsStatusGetResponseContent( 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( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -266,6 +301,8 @@ partial void ProcessGetRequestStatusFacesGsStatusGetResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -286,6 +323,8 @@ partial void ProcessGetRequestStatusFacesGsStatusGetResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Validation Error @@ -348,7 +387,11 @@ partial void ProcessGetRequestStatusFacesGsStatusGetResponseContent( { __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) { @@ -376,7 +419,11 @@ partial void ProcessGetRequestStatusFacesGsStatusGetResponseContent( #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) { diff --git a/src/libs/Simli/Generated/Simli.SimliClient.InitIntegrationsLivekitAgentsPost.g.cs b/src/libs/Simli/Generated/Simli.SimliClient.InitIntegrationsLivekitAgentsPost.g.cs index 8a04fe1..6fedf84 100644 --- a/src/libs/Simli/Generated/Simli.SimliClient.InitIntegrationsLivekitAgentsPost.g.cs +++ b/src/libs/Simli/Generated/Simli.SimliClient.InitIntegrationsLivekitAgentsPost.g.cs @@ -50,6 +50,28 @@ partial void ProcessInitIntegrationsLivekitAgentsPostResponseContent( /// public async global::System.Threading.Tasks.Task InitIntegrationsLivekitAgentsPostAsync( + global::Simli.LiveKitInitializationRequest request, + global::Simli.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await InitIntegrationsLivekitAgentsPostAsResponseAsync( + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Start Livekit Agents Session + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> InitIntegrationsLivekitAgentsPostAsResponseAsync( + global::Simli.LiveKitInitializationRequest request, global::Simli.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) @@ -84,6 +106,7 @@ partial void ProcessInitIntegrationsLivekitAgentsPostResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Simli.PathBuilder( path: "/integrations/livekit/agents", baseUri: HttpClient.BaseAddress); @@ -163,6 +186,8 @@ partial void ProcessInitIntegrationsLivekitAgentsPostResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -173,6 +198,11 @@ partial void ProcessInitIntegrationsLivekitAgentsPostResponseContent( } 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, @@ -190,6 +220,8 @@ partial void ProcessInitIntegrationsLivekitAgentsPostResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -199,8 +231,7 @@ partial void ProcessInitIntegrationsLivekitAgentsPostResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Simli.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -209,6 +240,11 @@ partial void ProcessInitIntegrationsLivekitAgentsPostResponseContent( __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( @@ -225,14 +261,15 @@ partial void ProcessInitIntegrationsLivekitAgentsPostResponseContent( 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( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -272,6 +309,8 @@ partial void ProcessInitIntegrationsLivekitAgentsPostResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -292,6 +331,8 @@ partial void ProcessInitIntegrationsLivekitAgentsPostResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Session Failed @@ -392,9 +433,13 @@ partial void ProcessInitIntegrationsLivekitAgentsPostResponseContent( { __response.EnsureSuccessStatusCode(); - return - global::Simli.InitIntegrationsLivekitAgentsPostResponse.FromJson(__content, JsonSerializerContext) ?? + var __value = global::Simli.InitIntegrationsLivekitAgentsPostResponse.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Simli.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Simli.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -422,9 +467,13 @@ partial void ProcessInitIntegrationsLivekitAgentsPostResponseContent( #endif ).ConfigureAwait(false); - return - await global::Simli.InitIntegrationsLivekitAgentsPostResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::Simli.InitIntegrationsLivekitAgentsPostResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Simli.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Simli.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { diff --git a/src/libs/Simli/Generated/Simli.SimliClient.StartAudioToVideoSessionComposeTokenPost.g.cs b/src/libs/Simli/Generated/Simli.SimliClient.StartAudioToVideoSessionComposeTokenPost.g.cs index ea3b302..49bcfe8 100644 --- a/src/libs/Simli/Generated/Simli.SimliClient.StartAudioToVideoSessionComposeTokenPost.g.cs +++ b/src/libs/Simli/Generated/Simli.SimliClient.StartAudioToVideoSessionComposeTokenPost.g.cs @@ -51,6 +51,29 @@ partial void ProcessStartAudioToVideoSessionComposeTokenPostResponseContent( /// public async global::System.Threading.Tasks.Task StartAudioToVideoSessionComposeTokenPostAsync( + global::Simli.StartStreamingSessionRequest request, + global::Simli.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await StartAudioToVideoSessionComposeTokenPostAsResponseAsync( + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Compose Session Token
+ /// Create a temporary Simli Compose Session Token + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> StartAudioToVideoSessionComposeTokenPostAsResponseAsync( + global::Simli.StartStreamingSessionRequest request, global::Simli.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) @@ -85,6 +108,7 @@ partial void ProcessStartAudioToVideoSessionComposeTokenPostResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Simli.PathBuilder( path: "/compose/token", baseUri: HttpClient.BaseAddress); @@ -164,6 +188,8 @@ partial void ProcessStartAudioToVideoSessionComposeTokenPostResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -174,6 +200,11 @@ partial void ProcessStartAudioToVideoSessionComposeTokenPostResponseContent( } 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, @@ -191,6 +222,8 @@ partial void ProcessStartAudioToVideoSessionComposeTokenPostResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -200,8 +233,7 @@ partial void ProcessStartAudioToVideoSessionComposeTokenPostResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Simli.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -210,6 +242,11 @@ partial void ProcessStartAudioToVideoSessionComposeTokenPostResponseContent( __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( @@ -226,14 +263,15 @@ partial void ProcessStartAudioToVideoSessionComposeTokenPostResponseContent( 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( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -273,6 +311,8 @@ partial void ProcessStartAudioToVideoSessionComposeTokenPostResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -293,6 +333,8 @@ partial void ProcessStartAudioToVideoSessionComposeTokenPostResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Invalid Data @@ -393,9 +435,13 @@ partial void ProcessStartAudioToVideoSessionComposeTokenPostResponseContent( { __response.EnsureSuccessStatusCode(); - return - global::Simli.StartAudioToVideoSessionComposeTokenPostResponse.FromJson(__content, JsonSerializerContext) ?? + var __value = global::Simli.StartAudioToVideoSessionComposeTokenPostResponse.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Simli.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Simli.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -423,9 +469,13 @@ partial void ProcessStartAudioToVideoSessionComposeTokenPostResponseContent( #endif ).ConfigureAwait(false); - return - await global::Simli.StartAudioToVideoSessionComposeTokenPostResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::Simli.StartAudioToVideoSessionComposeTokenPostResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Simli.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Simli.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { diff --git a/src/libs/Simli/Generated/Simli.SimliClient.g.cs b/src/libs/Simli/Generated/Simli.SimliClient.g.cs index 51e40fe..6f19dc7 100644 --- a/src/libs/Simli/Generated/Simli.SimliClient.g.cs +++ b/src/libs/Simli/Generated/Simli.SimliClient.g.cs @@ -72,10 +72,10 @@ public SimliClient( /// Client-wide request defaults such as headers, query parameters, retries, and timeout. /// Dispose the HttpClient when the instance is disposed. True by default. public SimliClient( - global::System.Net.Http.HttpClient? httpClient = null, - global::System.Uri? baseUri = null, - global::System.Collections.Generic.List? authorizations = null, - global::Simli.AutoSDKClientOptions? options = null, + global::System.Net.Http.HttpClient? httpClient, + global::System.Uri? baseUri, + global::System.Collections.Generic.List? authorizations, + global::Simli.AutoSDKClientOptions? options, bool disposeHttpClient = true) {