From 677a3c536e2a9a66d89ba043e1af43a0f70d4baf Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sun, 10 May 2026 18:59:24 +0000 Subject: [PATCH] feat: Updated OpenAPI spec --- ....CreateSpeechUnderstandingResponse200.g.cs | 15 ++ .../Generated/AssemblyAI.Models.Message.g.cs | 20 +++ .../AssemblyAI.Models.ToolChoice.g.cs | 10 ++ ...ionalParamsSpeechUnderstandingRequest.g.cs | 15 ++ ....TranscriptSpeechUnderstandingRequest.g.cs | 15 ++ ...TranscriptSpeechUnderstandingResponse.g.cs | 15 ++ ...dingRequestSpeechUnderstandingRequest.g.cs | 15 ++ ...els.UserAssistantSystemMessageContent.g.cs | 5 + .../Generated/AssemblyAI.OneOf.2.g.cs | 10 ++ .../Generated/AssemblyAI.OptionsSupport.g.cs | 150 ++++++++++++++++++ ...ssemblyAI.Realtime.Models.ServerEvent.g.cs | 20 +++ .../AssemblyAI.Realtime.OptionsSupport.g.cs | 150 ++++++++++++++++++ 12 files changed, 440 insertions(+) diff --git a/src/libs/AssemblyAI/Generated/AssemblyAI.Models.CreateSpeechUnderstandingResponse200.g.cs b/src/libs/AssemblyAI/Generated/AssemblyAI.Models.CreateSpeechUnderstandingResponse200.g.cs index 1a089fc..c7de0ba 100644 --- a/src/libs/AssemblyAI/Generated/AssemblyAI.Models.CreateSpeechUnderstandingResponse200.g.cs +++ b/src/libs/AssemblyAI/Generated/AssemblyAI.Models.CreateSpeechUnderstandingResponse200.g.cs @@ -116,6 +116,11 @@ public CreateSpeechUnderstandingResponse200(global::AssemblyAI.LLMGatewayTransla LLMGatewayTranslationResponse = value; } + /// + /// + /// + public static CreateSpeechUnderstandingResponse200 FromLLMGatewayTranslationResponse(global::AssemblyAI.LLMGatewayTranslationResponse? value) => new CreateSpeechUnderstandingResponse200(value); + /// /// /// @@ -134,6 +139,11 @@ public CreateSpeechUnderstandingResponse200(global::AssemblyAI.LLMGatewaySpeaker LLMGatewaySpeakerIdentificationResponse = value; } + /// + /// + /// + public static CreateSpeechUnderstandingResponse200 FromLLMGatewaySpeakerIdentificationResponse(global::AssemblyAI.LLMGatewaySpeakerIdentificationResponse? value) => new CreateSpeechUnderstandingResponse200(value); + /// /// /// @@ -152,6 +162,11 @@ public CreateSpeechUnderstandingResponse200(global::AssemblyAI.LLMGatewayCustomF LLMGatewayCustomFormattingResponse = value; } + /// + /// + /// + public static CreateSpeechUnderstandingResponse200 FromLLMGatewayCustomFormattingResponse(global::AssemblyAI.LLMGatewayCustomFormattingResponse? value) => new CreateSpeechUnderstandingResponse200(value); + /// /// /// diff --git a/src/libs/AssemblyAI/Generated/AssemblyAI.Models.Message.g.cs b/src/libs/AssemblyAI/Generated/AssemblyAI.Models.Message.g.cs index 3982755..b8722f2 100644 --- a/src/libs/AssemblyAI/Generated/AssemblyAI.Models.Message.g.cs +++ b/src/libs/AssemblyAI/Generated/AssemblyAI.Models.Message.g.cs @@ -146,6 +146,11 @@ public Message(global::AssemblyAI.MessageVariant1? value) MessageVariant1 = value; } + /// + /// + /// + public static Message FromMessageVariant1(global::AssemblyAI.MessageVariant1? value) => new Message(value); + /// /// /// @@ -164,6 +169,11 @@ public Message(global::AssemblyAI.MessageVariant2? value) MessageVariant2 = value; } + /// + /// + /// + public static Message FromMessageVariant2(global::AssemblyAI.MessageVariant2? value) => new Message(value); + /// /// /// @@ -182,6 +192,11 @@ public Message(global::AssemblyAI.MessageVariant3? value) MessageVariant3 = value; } + /// + /// + /// + public static Message FromMessageVariant3(global::AssemblyAI.MessageVariant3? value) => new Message(value); + /// /// /// @@ -200,6 +215,11 @@ public Message(global::AssemblyAI.MessageVariant4? value) Tool = value; } + /// + /// + /// + public static Message FromTool(global::AssemblyAI.MessageVariant4? value) => new Message(value); + /// /// /// diff --git a/src/libs/AssemblyAI/Generated/AssemblyAI.Models.ToolChoice.g.cs b/src/libs/AssemblyAI/Generated/AssemblyAI.Models.ToolChoice.g.cs index 73ecb03..10e58ab 100644 --- a/src/libs/AssemblyAI/Generated/AssemblyAI.Models.ToolChoice.g.cs +++ b/src/libs/AssemblyAI/Generated/AssemblyAI.Models.ToolChoice.g.cs @@ -86,6 +86,11 @@ public ToolChoice(global::AssemblyAI.ToolChoice0? value) ToolChoice0 = value; } + /// + /// + /// + public static ToolChoice FromToolChoice0(global::AssemblyAI.ToolChoice0? value) => new ToolChoice(value); + /// /// /// @@ -104,6 +109,11 @@ public ToolChoice(global::AssemblyAI.ToolChoice1? value) ToolChoice1 = value; } + /// + /// + /// + public static ToolChoice FromToolChoice1(global::AssemblyAI.ToolChoice1? value) => new ToolChoice(value); + /// /// /// diff --git a/src/libs/AssemblyAI/Generated/AssemblyAI.Models.TranscriptOptionalParamsSpeechUnderstandingRequest.g.cs b/src/libs/AssemblyAI/Generated/AssemblyAI.Models.TranscriptOptionalParamsSpeechUnderstandingRequest.g.cs index c68d30f..8c5e214 100644 --- a/src/libs/AssemblyAI/Generated/AssemblyAI.Models.TranscriptOptionalParamsSpeechUnderstandingRequest.g.cs +++ b/src/libs/AssemblyAI/Generated/AssemblyAI.Models.TranscriptOptionalParamsSpeechUnderstandingRequest.g.cs @@ -116,6 +116,11 @@ public TranscriptOptionalParamsSpeechUnderstandingRequest(global::AssemblyAI.Tra TranslationRequestBody = value; } + /// + /// + /// + public static TranscriptOptionalParamsSpeechUnderstandingRequest FromTranslationRequestBody(global::AssemblyAI.TranslationRequestBody? value) => new TranscriptOptionalParamsSpeechUnderstandingRequest(value); + /// /// /// @@ -134,6 +139,11 @@ public TranscriptOptionalParamsSpeechUnderstandingRequest(global::AssemblyAI.Spe SpeakerIdentificationRequestBody = value; } + /// + /// + /// + public static TranscriptOptionalParamsSpeechUnderstandingRequest FromSpeakerIdentificationRequestBody(global::AssemblyAI.SpeakerIdentificationRequestBody? value) => new TranscriptOptionalParamsSpeechUnderstandingRequest(value); + /// /// /// @@ -152,6 +162,11 @@ public TranscriptOptionalParamsSpeechUnderstandingRequest(global::AssemblyAI.Cus CustomFormattingRequestBody = value; } + /// + /// + /// + public static TranscriptOptionalParamsSpeechUnderstandingRequest FromCustomFormattingRequestBody(global::AssemblyAI.CustomFormattingRequestBody? value) => new TranscriptOptionalParamsSpeechUnderstandingRequest(value); + /// /// /// diff --git a/src/libs/AssemblyAI/Generated/AssemblyAI.Models.TranscriptSpeechUnderstandingRequest.g.cs b/src/libs/AssemblyAI/Generated/AssemblyAI.Models.TranscriptSpeechUnderstandingRequest.g.cs index a0b32b9..5865740 100644 --- a/src/libs/AssemblyAI/Generated/AssemblyAI.Models.TranscriptSpeechUnderstandingRequest.g.cs +++ b/src/libs/AssemblyAI/Generated/AssemblyAI.Models.TranscriptSpeechUnderstandingRequest.g.cs @@ -116,6 +116,11 @@ public TranscriptSpeechUnderstandingRequest(global::AssemblyAI.TranslationReques TranslationRequestBody = value; } + /// + /// + /// + public static TranscriptSpeechUnderstandingRequest FromTranslationRequestBody(global::AssemblyAI.TranslationRequestBody? value) => new TranscriptSpeechUnderstandingRequest(value); + /// /// /// @@ -134,6 +139,11 @@ public TranscriptSpeechUnderstandingRequest(global::AssemblyAI.SpeakerIdentifica SpeakerIdentificationRequestBody = value; } + /// + /// + /// + public static TranscriptSpeechUnderstandingRequest FromSpeakerIdentificationRequestBody(global::AssemblyAI.SpeakerIdentificationRequestBody? value) => new TranscriptSpeechUnderstandingRequest(value); + /// /// /// @@ -152,6 +162,11 @@ public TranscriptSpeechUnderstandingRequest(global::AssemblyAI.CustomFormattingR CustomFormattingRequestBody = value; } + /// + /// + /// + public static TranscriptSpeechUnderstandingRequest FromCustomFormattingRequestBody(global::AssemblyAI.CustomFormattingRequestBody? value) => new TranscriptSpeechUnderstandingRequest(value); + /// /// /// diff --git a/src/libs/AssemblyAI/Generated/AssemblyAI.Models.TranscriptSpeechUnderstandingResponse.g.cs b/src/libs/AssemblyAI/Generated/AssemblyAI.Models.TranscriptSpeechUnderstandingResponse.g.cs index 553fce8..3418b1d 100644 --- a/src/libs/AssemblyAI/Generated/AssemblyAI.Models.TranscriptSpeechUnderstandingResponse.g.cs +++ b/src/libs/AssemblyAI/Generated/AssemblyAI.Models.TranscriptSpeechUnderstandingResponse.g.cs @@ -116,6 +116,11 @@ public TranscriptSpeechUnderstandingResponse(global::AssemblyAI.TranslationRespo TranslationResponse = value; } + /// + /// + /// + public static TranscriptSpeechUnderstandingResponse FromTranslationResponse(global::AssemblyAI.TranslationResponse? value) => new TranscriptSpeechUnderstandingResponse(value); + /// /// /// @@ -134,6 +139,11 @@ public TranscriptSpeechUnderstandingResponse(global::AssemblyAI.SpeakerIdentific SpeakerIdentificationResponse = value; } + /// + /// + /// + public static TranscriptSpeechUnderstandingResponse FromSpeakerIdentificationResponse(global::AssemblyAI.SpeakerIdentificationResponse? value) => new TranscriptSpeechUnderstandingResponse(value); + /// /// /// @@ -152,6 +162,11 @@ public TranscriptSpeechUnderstandingResponse(global::AssemblyAI.CustomFormatting CustomFormattingResponse = value; } + /// + /// + /// + public static TranscriptSpeechUnderstandingResponse FromCustomFormattingResponse(global::AssemblyAI.CustomFormattingResponse? value) => new TranscriptSpeechUnderstandingResponse(value); + /// /// /// diff --git a/src/libs/AssemblyAI/Generated/AssemblyAI.Models.UnderstandingRequestSpeechUnderstandingRequest.g.cs b/src/libs/AssemblyAI/Generated/AssemblyAI.Models.UnderstandingRequestSpeechUnderstandingRequest.g.cs index afa652a..0b51750 100644 --- a/src/libs/AssemblyAI/Generated/AssemblyAI.Models.UnderstandingRequestSpeechUnderstandingRequest.g.cs +++ b/src/libs/AssemblyAI/Generated/AssemblyAI.Models.UnderstandingRequestSpeechUnderstandingRequest.g.cs @@ -116,6 +116,11 @@ public UnderstandingRequestSpeechUnderstandingRequest(global::AssemblyAI.Transla TranslationRequestBody = value; } + /// + /// + /// + public static UnderstandingRequestSpeechUnderstandingRequest FromTranslationRequestBody(global::AssemblyAI.TranslationRequestBody? value) => new UnderstandingRequestSpeechUnderstandingRequest(value); + /// /// /// @@ -134,6 +139,11 @@ public UnderstandingRequestSpeechUnderstandingRequest(global::AssemblyAI.Speaker SpeakerIdentificationRequestBody = value; } + /// + /// + /// + public static UnderstandingRequestSpeechUnderstandingRequest FromSpeakerIdentificationRequestBody(global::AssemblyAI.SpeakerIdentificationRequestBody? value) => new UnderstandingRequestSpeechUnderstandingRequest(value); + /// /// /// @@ -152,6 +162,11 @@ public UnderstandingRequestSpeechUnderstandingRequest(global::AssemblyAI.CustomF CustomFormattingRequestBody = value; } + /// + /// + /// + public static UnderstandingRequestSpeechUnderstandingRequest FromCustomFormattingRequestBody(global::AssemblyAI.CustomFormattingRequestBody? value) => new UnderstandingRequestSpeechUnderstandingRequest(value); + /// /// /// diff --git a/src/libs/AssemblyAI/Generated/AssemblyAI.Models.UserAssistantSystemMessageContent.g.cs b/src/libs/AssemblyAI/Generated/AssemblyAI.Models.UserAssistantSystemMessageContent.g.cs index fca3692..9a4179a 100644 --- a/src/libs/AssemblyAI/Generated/AssemblyAI.Models.UserAssistantSystemMessageContent.g.cs +++ b/src/libs/AssemblyAI/Generated/AssemblyAI.Models.UserAssistantSystemMessageContent.g.cs @@ -86,6 +86,11 @@ public UserAssistantSystemMessageContent(string? value) UserAssistantSystemMessageContentVariant1 = value; } + /// + /// + /// + public static UserAssistantSystemMessageContent FromUserAssistantSystemMessageContentVariant1(string? value) => new UserAssistantSystemMessageContent(value); + /// /// /// diff --git a/src/libs/AssemblyAI/Generated/AssemblyAI.OneOf.2.g.cs b/src/libs/AssemblyAI/Generated/AssemblyAI.OneOf.2.g.cs index 3b70b5c..81d4a5d 100644 --- a/src/libs/AssemblyAI/Generated/AssemblyAI.OneOf.2.g.cs +++ b/src/libs/AssemblyAI/Generated/AssemblyAI.OneOf.2.g.cs @@ -85,6 +85,11 @@ public OneOf(T1? value) Value1 = value; } + /// + /// + /// + public static OneOf FromValue1(T1? value) => new OneOf(value); + /// /// /// @@ -103,6 +108,11 @@ public OneOf(T2? value) Value2 = value; } + /// + /// + /// + public static OneOf FromValue2(T2? value) => new OneOf(value); + /// /// /// diff --git a/src/libs/AssemblyAI/Generated/AssemblyAI.OptionsSupport.g.cs b/src/libs/AssemblyAI/Generated/AssemblyAI.OptionsSupport.g.cs index 8431379..23cb5de 100644 --- a/src/libs/AssemblyAI/Generated/AssemblyAI.OptionsSupport.g.cs +++ b/src/libs/AssemblyAI/Generated/AssemblyAI.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::AssemblyAI.IAutoSDKAuthorizationProvider? AuthorizationProvider { get; set; } + + /// + /// Convenience helper that registers + /// using so request-level auth is resolved without + /// touching shared client state. + /// + /// + public global::AssemblyAI.AutoSDKClientOptions UseAuthorizationProvider( + global::AssemblyAI.IAutoSDKAuthorizationProvider provider) + { + AuthorizationProvider = provider ?? throw new global::System.ArgumentNullException(nameof(provider)); + if (Hooks.Find(static x => x is global::AssemblyAI.AutoSDKAuthorizationProviderHook) == null) + { + Hooks.Add(new global::AssemblyAI.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::AssemblyAI.AutoSDKAuthorizationValue Bearer(string token) => new(value: token, scheme: "Bearer"); + + /// Convenience factory for an API-key header. + public static global::AssemblyAI.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::AssemblyAI.AutoSDKHookContext context); + } + + /// + /// Built-in that consults + /// before every outgoing + /// request and stamps the resolved values onto the . + /// + public sealed class AutoSDKAuthorizationProviderHook : global::AssemblyAI.AutoSDKHook + { + /// + public override async global::System.Threading.Tasks.Task OnBeforeRequestAsync( + global::AssemblyAI.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::AssemblyAI.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; + } + } } /// diff --git a/src/libs/AssemblyAI/Generated/AssemblyAI.Realtime.Models.ServerEvent.g.cs b/src/libs/AssemblyAI/Generated/AssemblyAI.Realtime.Models.ServerEvent.g.cs index d996815..2f5df14 100644 --- a/src/libs/AssemblyAI/Generated/AssemblyAI.Realtime.Models.ServerEvent.g.cs +++ b/src/libs/AssemblyAI/Generated/AssemblyAI.Realtime.Models.ServerEvent.g.cs @@ -151,6 +151,11 @@ public ServerEvent(global::AssemblyAI.Realtime.SessionBeginsPayload? value) Begin = value; } + /// + /// + /// + public static ServerEvent FromBegin(global::AssemblyAI.Realtime.SessionBeginsPayload? value) => new ServerEvent(value); + /// /// /// @@ -169,6 +174,11 @@ public ServerEvent(global::AssemblyAI.Realtime.TurnPayload? value) Turn = value; } + /// + /// + /// + public static ServerEvent FromTurn(global::AssemblyAI.Realtime.TurnPayload? value) => new ServerEvent(value); + /// /// /// @@ -187,6 +197,11 @@ public ServerEvent(global::AssemblyAI.Realtime.TerminationPayload? value) Termination = value; } + /// + /// + /// + public static ServerEvent FromTermination(global::AssemblyAI.Realtime.TerminationPayload? value) => new ServerEvent(value); + /// /// /// @@ -205,6 +220,11 @@ public ServerEvent(global::AssemblyAI.Realtime.ErrorPayload? value) Error = value; } + /// + /// + /// + public static ServerEvent FromError(global::AssemblyAI.Realtime.ErrorPayload? value) => new ServerEvent(value); + /// /// /// diff --git a/src/libs/AssemblyAI/Generated/AssemblyAI.Realtime.OptionsSupport.g.cs b/src/libs/AssemblyAI/Generated/AssemblyAI.Realtime.OptionsSupport.g.cs index 67a0e36..1740138 100644 --- a/src/libs/AssemblyAI/Generated/AssemblyAI.Realtime.OptionsSupport.g.cs +++ b/src/libs/AssemblyAI/Generated/AssemblyAI.Realtime.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::AssemblyAI.Realtime.IAutoSDKAuthorizationProvider? AuthorizationProvider { get; set; } + + /// + /// Convenience helper that registers + /// using so request-level auth is resolved without + /// touching shared client state. + /// + /// + public global::AssemblyAI.Realtime.AutoSDKClientOptions UseAuthorizationProvider( + global::AssemblyAI.Realtime.IAutoSDKAuthorizationProvider provider) + { + AuthorizationProvider = provider ?? throw new global::System.ArgumentNullException(nameof(provider)); + if (Hooks.Find(static x => x is global::AssemblyAI.Realtime.AutoSDKAuthorizationProviderHook) == null) + { + Hooks.Add(new global::AssemblyAI.Realtime.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::AssemblyAI.Realtime.AutoSDKAuthorizationValue Bearer(string token) => new(value: token, scheme: "Bearer"); + + /// Convenience factory for an API-key header. + public static global::AssemblyAI.Realtime.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::AssemblyAI.Realtime.AutoSDKHookContext context); + } + + /// + /// Built-in that consults + /// before every outgoing + /// request and stamps the resolved values onto the . + /// + public sealed class AutoSDKAuthorizationProviderHook : global::AssemblyAI.Realtime.AutoSDKHook + { + /// + public override async global::System.Threading.Tasks.Task OnBeforeRequestAsync( + global::AssemblyAI.Realtime.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::AssemblyAI.Realtime.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; + } + } } ///