Class DocumentAnalysisClientBuilder


  • public final class DocumentAnalysisClientBuilder
    extends Object
    This class provides a fluent builder API to help instantiation of DocumentAnalysisClients and DocumentAnalysisAsyncClients, call buildClient() buildClient} and buildAsyncClient respectively to construct an instance of the desired client.

    The client needs the service endpoint of the Azure Document Analysis to access the resource service. credential(AzureKeyCredential) or credential(TokenCredential) gives the builder access credential.

    Instantiating an asynchronous Document Analysis Client

     DocumentAnalysisAsyncClient documentAnalysisAsyncClient = new DocumentAnalysisClientBuilder()
         .credential(new AzureKeyCredential("{key}"))
         .endpoint("{endpoint}")
         .buildAsyncClient();
     

    Instantiating a synchronous Document Analysis Client

     DocumentAnalysisClient documentAnalysisClient = new DocumentAnalysisClientBuilder()
         .credential(new AzureKeyCredential("{key}"))
         .endpoint("{endpoint}")
         .buildClient();
     

    Another way to construct the client is using a HttpPipeline. The pipeline gives the client an authenticated way to communicate with the service. Set the pipeline with this and set the service endpoint with this. Using a pipeline requires additional setup but allows for finer control on how the DocumentAnalysisClient and DocumentAnalysisAsyncClient is built.

     HttpPipeline pipeline = new HttpPipelineBuilder()
         .policies(/* add policies */)
         .build();
    
     DocumentAnalysisClient documentAnalysisClient = new DocumentAnalysisClientBuilder()
         .credential(new AzureKeyCredential("{key}"))
         .endpoint("{endpoint}")
         .pipeline(pipeline)
         .buildClient();
     
    See Also:
    DocumentAnalysisAsyncClient, DocumentAnalysisClient
    • Constructor Detail

      • DocumentAnalysisClientBuilder

        public DocumentAnalysisClientBuilder()
    • Method Detail

      • endpoint

        public DocumentAnalysisClientBuilder endpoint​(String endpoint)
        Sets the service endpoint for the Azure Document Analysis instance.
        Parameters:
        endpoint - The URL of the Azure Document Analysis instance service requests to and receive responses from.
        Returns:
        The updated DocumentAnalysisClientBuilder object.
        Throws:
        NullPointerException - if endpoint is null
        IllegalArgumentException - if endpoint cannot be parsed into a valid URL.
      • credential

        public DocumentAnalysisClientBuilder credential​(com.azure.core.credential.AzureKeyCredential azureKeyCredential)
        Sets the AzureKeyCredential to use when authenticating HTTP requests for this DocumentAnalysisClientBuilder.
        Parameters:
        azureKeyCredential - AzureKeyCredential API key credential
        Returns:
        The updated DocumentAnalysisClientBuilder object.
        Throws:
        NullPointerException - If azureKeyCredential is null.
      • httpLogOptions

        public DocumentAnalysisClientBuilder httpLogOptions​(com.azure.core.http.policy.HttpLogOptions logOptions)
        Sets the logging configuration for HTTP requests and responses.

        If logOptions isn't provided, the default options will use HttpLogDetailLevel.NONE which will prevent logging.

        Parameters:
        logOptions - The logging configuration to use when sending and receiving HTTP requests/responses.
        Returns:
        The updated DocumentAnalysisClientBuilder object.
      • getDefaultLogOptions

        public static com.azure.core.http.policy.HttpLogOptions getDefaultLogOptions()
        Gets the default Azure Document Analysis client headers and query parameters that are logged by default if HTTP logging is enabled.
        Returns:
        The default HttpLogOptions allow list.
      • clientOptions

        public DocumentAnalysisClientBuilder clientOptions​(com.azure.core.util.ClientOptions clientOptions)
        Sets the client options such as application ID and custom headers to set on a request.
        Parameters:
        clientOptions - The client options.
        Returns:
        The updated DocumentAnalysisClientBuilder object.
      • addPolicy

        public DocumentAnalysisClientBuilder addPolicy​(com.azure.core.http.policy.HttpPipelinePolicy policy)
        Adds a policy to the set of existing policies that are executed after required policies.
        Parameters:
        policy - The retry policy for service requests.
        Returns:
        The updated DocumentAnalysisClientBuilder object.
        Throws:
        NullPointerException - If policy is null.
      • httpClient

        public DocumentAnalysisClientBuilder httpClient​(com.azure.core.http.HttpClient client)
        Sets the HTTP client to use for sending and receiving requests to and from the service.
        Parameters:
        client - The HTTP client to use for requests.
        Returns:
        The updated DocumentAnalysisClientBuilder object.
      • pipeline

        public DocumentAnalysisClientBuilder pipeline​(com.azure.core.http.HttpPipeline httpPipeline)
        Sets the HTTP pipeline to use for the service client.

        If pipeline is set, all other settings are ignored, aside from endpoint to build DocumentAnalysisAsyncClient or DocumentAnalysisClient.

        Parameters:
        httpPipeline - The HTTP pipeline to use for sending service requests and receiving responses.
        Returns:
        The updated DocumentAnalysisClientBuilder object.
      • configuration

        public DocumentAnalysisClientBuilder configuration​(com.azure.core.util.Configuration configuration)
        Sets the configuration store that is used during construction of the service client.

        The default configuration store is a clone of the global configuration store, use Configuration.NONE to bypass using configuration settings during construction.

        Parameters:
        configuration - The configuration store used to.
        Returns:
        The updated DocumentAnalysisClientBuilder object.
      • serviceVersion

        public DocumentAnalysisClientBuilder serviceVersion​(DocumentAnalysisServiceVersion version)
        Sets the DocumentAnalysisServiceVersion that is used when making API requests.

        If a service version is not provided, the service version that will be used will be the latest known service version based on the version of the client library being used. If no service version is specified, updating to a newer version the client library will have the result of potentially moving to a newer service version.

        Parameters:
        version - DocumentAnalysisServiceVersion of the service to be used when making requests.
        Returns:
        The updated DocumentAnalysisClientBuilder object.