// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. // #nullable disable using System; using System.Diagnostics.CodeAnalysis; using Azure; using Azure.AI.Language.Documents; using Azure.Core.Extensions; namespace Microsoft.Extensions.Azure { /// Extension methods to add clients to . public static partial class LanguageDocumentsClientBuilderExtensions { /// Registers a client with the specified . /// The builder to register with. /// Supported Cognitive Services endpoint (e.g., https://<resource-name>.api.cognitiveservices.azure.com). /// A credential used to authenticate to the service. /// or is null. /// is an empty string, and was expected to be non-empty. public static IAzureClientBuilder AddDocumentAnalysisClient(this TBuilder builder, string endpoint, AzureKeyCredential credential) where TBuilder : IAzureClientFactoryBuilder { Argument.AssertNotNullOrEmpty(endpoint, nameof(endpoint)); Argument.AssertNotNull(credential, nameof(credential)); return builder.RegisterClientFactory(options => new DocumentAnalysisClient(endpoint, credential, options)); } /// Registers a client with the specified . /// The builder to register with. /// Supported Cognitive Services endpoint (e.g., https://<resource-name>.api.cognitiveservices.azure.com). /// is null. /// is an empty string, and was expected to be non-empty. public static IAzureClientBuilder AddDocumentAnalysisClient(this TBuilder builder, string endpoint) where TBuilder : IAzureClientFactoryBuilderWithCredential { Argument.AssertNotNullOrEmpty(endpoint, nameof(endpoint)); return builder.RegisterClientFactory((options, credential) => new DocumentAnalysisClient(endpoint, credential, options)); } /// Registers a client with the specified . /// The builder to register with. /// The configuration to use for the client. [RequiresUnreferencedCode("Requires unreferenced code until we opt into EnableConfigurationBindingGenerator.")] [RequiresDynamicCode("Requires unreferenced code until we opt into EnableConfigurationBindingGenerator.")] public static IAzureClientBuilder AddDocumentAnalysisClient(this TBuilder builder, TConfiguration configuration) where TBuilder : IAzureClientFactoryBuilderWithConfiguration { return builder.RegisterClientFactory(configuration); } } }