diff --git a/src/libs/Gladia/Generated/Gladia.Models.TranscriptionControllerGetTranscriptV2Response.g.cs b/src/libs/Gladia/Generated/Gladia.Models.TranscriptionControllerGetTranscriptV2Response.g.cs index 5c1b93e..e499559 100644 --- a/src/libs/Gladia/Generated/Gladia.Models.TranscriptionControllerGetTranscriptV2Response.g.cs +++ b/src/libs/Gladia/Generated/Gladia.Models.TranscriptionControllerGetTranscriptV2Response.g.cs @@ -44,6 +44,13 @@ public bool TryPickPreRecorded( return IsPreRecorded; } + /// + /// + /// + public global::Gladia.PreRecordedResponse PickPreRecorded() => IsPreRecorded + ? PreRecorded! + : throw new global::System.InvalidOperationException($"Expected union variant 'PreRecorded' but the value was {ToString()}."); + /// /// /// @@ -73,6 +80,13 @@ public bool TryPickLive( value = Live; return IsLive; } + + /// + /// + /// + public global::Gladia.StreamingResponse PickLive() => IsLive + ? Live! + : throw new global::System.InvalidOperationException($"Expected union variant 'Live' but the value was {ToString()}."); /// /// /// @@ -91,6 +105,11 @@ public TranscriptionControllerGetTranscriptV2Response(global::Gladia.PreRecorded PreRecorded = value; } + /// + /// + /// + public static TranscriptionControllerGetTranscriptV2Response FromPreRecorded(global::Gladia.PreRecordedResponse? value) => new TranscriptionControllerGetTranscriptV2Response(value); + /// /// /// @@ -109,6 +128,11 @@ public TranscriptionControllerGetTranscriptV2Response(global::Gladia.StreamingRe Live = value; } + /// + /// + /// + public static TranscriptionControllerGetTranscriptV2Response FromLive(global::Gladia.StreamingResponse? value) => new TranscriptionControllerGetTranscriptV2Response(value); + /// /// /// diff --git a/src/libs/Gladia/Generated/Gladia.OneOf.2.g.cs b/src/libs/Gladia/Generated/Gladia.OneOf.2.g.cs index c0d41a7..0db0d9c 100644 --- a/src/libs/Gladia/Generated/Gladia.OneOf.2.g.cs +++ b/src/libs/Gladia/Generated/Gladia.OneOf.2.g.cs @@ -38,6 +38,13 @@ public bool TryPickValue1( return IsValue1; } + /// + /// + /// + public T1 PickValue1() => IsValue1 + ? Value1! + : throw new global::System.InvalidOperationException($"Expected union variant 'Value1' but the value was {ToString()}."); + /// /// /// @@ -67,6 +74,13 @@ public bool TryPickValue2( value = Value2; return IsValue2; } + + /// + /// + /// + public T2 PickValue2() => IsValue2 + ? Value2! + : throw new global::System.InvalidOperationException($"Expected union variant 'Value2' but the value was {ToString()}."); /// /// /// @@ -85,6 +99,11 @@ public OneOf(T1? value) Value1 = value; } + /// + /// + /// + public static OneOf FromValue1(T1? value) => new OneOf(value); + /// /// /// @@ -103,6 +122,11 @@ public OneOf(T2? value) Value2 = value; } + /// + /// + /// + public static OneOf FromValue2(T2? value) => new OneOf(value); + /// /// /// diff --git a/src/libs/Gladia/Generated/Gladia.OptionsSupport.g.cs b/src/libs/Gladia/Generated/Gladia.OptionsSupport.g.cs index a1300e6..2d5f1ef 100644 --- a/src/libs/Gladia/Generated/Gladia.OptionsSupport.g.cs +++ b/src/libs/Gladia/Generated/Gladia.OptionsSupport.g.cs @@ -54,6 +54,156 @@ public sealed class AutoSDKClientOptions Hooks.Add(hook ?? throw new global::System.ArgumentNullException(nameof(hook))); return this; } + + /// + /// Optional per-request authorization provider invoked before each request is sent. + /// Set this when the client is registered as a singleton in DI but each call needs + /// a fresh credential resolved from a provider, secret-store, or session — instead + /// of mutating the shared Authorizations list at construction time. + /// + public global::Gladia.IAutoSDKAuthorizationProvider? AuthorizationProvider { get; set; } + + /// + /// Convenience helper that registers + /// using so request-level auth is resolved without + /// touching shared client state. + /// + /// + public global::Gladia.AutoSDKClientOptions UseAuthorizationProvider( + global::Gladia.IAutoSDKAuthorizationProvider provider) + { + AuthorizationProvider = provider ?? throw new global::System.ArgumentNullException(nameof(provider)); + if (Hooks.Find(static x => x is global::Gladia.AutoSDKAuthorizationProviderHook) == null) + { + Hooks.Add(new global::Gladia.AutoSDKAuthorizationProviderHook()); + } + + return this; + } + } + + /// + /// A request-level authorization value supplied by . + /// Mirrors the runtime fields the SDK applies for HTTP / OAuth2 / API-key auth without + /// requiring the consumer to construct the generated EndPointAuthorization type. + /// + public readonly struct AutoSDKAuthorizationValue + { + /// + /// Initializes a new . + /// + /// + /// + /// + /// + /// + public AutoSDKAuthorizationValue( + string value, + string scheme = "Bearer", + string? headerName = null, + string location = "Header", + string type = "Http") + { + Value = value ?? string.Empty; + Scheme = string.IsNullOrWhiteSpace(scheme) ? "Bearer" : scheme; + HeaderName = headerName ?? string.Empty; + Location = string.IsNullOrWhiteSpace(location) ? "Header" : location; + Type = string.IsNullOrWhiteSpace(type) ? "Http" : type; + } + + /// The credential value (token, API key, etc.). + public string Value { get; } + + /// The HTTP authorization scheme — typically Bearer, Basic, or Token. + public string Scheme { get; } + + /// The custom header name when is ApiKey; ignored for HTTP/OAuth2 auth. + public string HeaderName { get; } + + /// The credential location — Header, Query, or Cookie. + public string Location { get; } + + /// The auth type — Http, OAuth2, OpenIdConnect, or ApiKey. + public string Type { get; } + + /// Convenience factory for a Bearer token. + public static global::Gladia.AutoSDKAuthorizationValue Bearer(string token) => new(value: token, scheme: "Bearer"); + + /// Convenience factory for an API-key header. + public static global::Gladia.AutoSDKAuthorizationValue ApiKeyHeader(string name, string value) => + new(value: value, headerName: name, location: "Header", type: "ApiKey"); + } + + /// + /// Resolves request-level authorization values without mutating the shared client + /// authorization list. Implementations should be safe to invoke concurrently — + /// the hook calls them once per outgoing request. + /// + public interface IAutoSDKAuthorizationProvider + { + /// + /// Returns one or more values to apply to + /// the current request, or an empty list / null to leave the request as-is. + /// + /// + global::System.Threading.Tasks.Task?> ResolveAsync( + global::Gladia.AutoSDKHookContext context); + } + + /// + /// Built-in that consults + /// before every outgoing + /// request and stamps the resolved values onto the . + /// + public sealed class AutoSDKAuthorizationProviderHook : global::Gladia.AutoSDKHook + { + /// + public override async global::System.Threading.Tasks.Task OnBeforeRequestAsync( + global::Gladia.AutoSDKHookContext context) + { + context = context ?? throw new global::System.ArgumentNullException(nameof(context)); + + var provider = context.ClientOptions?.AuthorizationProvider; + if (provider == null || context.Request == null) + { + return; + } + + var resolved = await provider.ResolveAsync(context).ConfigureAwait(false); + if (resolved == null || resolved.Count == 0) + { + return; + } + + for (var index = 0; index < resolved.Count; index++) + { + ApplyAuthorization(context.Request, resolved[index]); + } + } + + private static void ApplyAuthorization( + global::System.Net.Http.HttpRequestMessage request, + global::Gladia.AutoSDKAuthorizationValue authorization) + { + switch (authorization.Type) + { + case "Http": + case "OAuth2": + case "OpenIdConnect": + request.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: authorization.Scheme, + parameter: authorization.Value); + break; + case "ApiKey": + if (string.Equals(authorization.Location, "Header", global::System.StringComparison.OrdinalIgnoreCase) && + !string.IsNullOrEmpty(authorization.HeaderName)) + { + request.Headers.Remove(authorization.HeaderName); + request.Headers.TryAddWithoutValidation(authorization.HeaderName, authorization.Value ?? string.Empty); + } + break; + } + } } ///