Class MetricsQueryClientBuilder

java.lang.Object
com.azure.monitor.query.MetricsQueryClientBuilder
All Implemented Interfaces:
com.azure.core.client.traits.ConfigurationTrait<MetricsQueryClientBuilder>, com.azure.core.client.traits.EndpointTrait<MetricsQueryClientBuilder>, com.azure.core.client.traits.HttpTrait<MetricsQueryClientBuilder>, com.azure.core.client.traits.TokenCredentialTrait<MetricsQueryClientBuilder>

public final class MetricsQueryClientBuilder extends Object implements com.azure.core.client.traits.EndpointTrait<MetricsQueryClientBuilder>, com.azure.core.client.traits.HttpTrait<MetricsQueryClientBuilder>, com.azure.core.client.traits.ConfigurationTrait<MetricsQueryClientBuilder>, com.azure.core.client.traits.TokenCredentialTrait<MetricsQueryClientBuilder>

Fluent builder for creating instances of MetricsQueryClient and MetricsQueryAsyncClient.

The MetricsQueryClientBuilder is responsible for authenticating a building instances of MetricsQueryClient and MetricsQueryAsyncClient. Customizations can be applied to clients through the builder using the various options available.

Getting Started

To create instances of the clients, sufficient authentication credentials are required. TokenCredential is a common form of authentication. The resource / workspace is not required for client creation, but the authentication credentials must have access to the resources / workspaces utilized by the client.

Client Builder Usage

The following sample shows instantiating an asynchronous Metrics query Client using Token Credential

 MetricsQueryAsyncClient metricsQueryAsyncClient = new MetricsQueryClientBuilder()
         .credential(tokenCredential)
         .buildAsyncClient();
 

The following sample shows instantiating a synchronous Metrics query Client using Token Credential

 MetricsQueryClient metricsQueryClient = new MetricsQueryClientBuilder()
         .credential(tokenCredential)
         .buildClient();
 

For more information about the other types of credentials that can be used to authenticate your client, please see this documentation: Azure Identity

See Also:
  • Constructor Details

    • MetricsQueryClientBuilder

      public MetricsQueryClientBuilder()
      Creates an instance of MetricsQueryClientBuilder.
  • Method Details

    • endpoint

      public MetricsQueryClientBuilder endpoint(String endpoint)
      Sets the metrics query endpoint.
      Specified by:
      endpoint in interface com.azure.core.client.traits.EndpointTrait<MetricsQueryClientBuilder>
      Parameters:
      endpoint - the host value.
      Returns:
      the MetricsClientBuilder.
    • pipeline

      public MetricsQueryClientBuilder pipeline(com.azure.core.http.HttpPipeline pipeline)
      Sets The HTTP pipeline to send requests through.
      Specified by:
      pipeline in interface com.azure.core.client.traits.HttpTrait<MetricsQueryClientBuilder>
      Parameters:
      pipeline - the pipeline value.
      Returns:
      the MetricsClientBuilder.
    • httpClient

      public MetricsQueryClientBuilder httpClient(com.azure.core.http.HttpClient httpClient)
      Sets The HTTP client used to send the request.
      Specified by:
      httpClient in interface com.azure.core.client.traits.HttpTrait<MetricsQueryClientBuilder>
      Parameters:
      httpClient - the httpClient value.
      Returns:
      the MetricsClientBuilder.
    • configuration

      public MetricsQueryClientBuilder configuration(com.azure.core.util.Configuration configuration)
      Sets The configuration store that is used during construction of the service client.
      Specified by:
      configuration in interface com.azure.core.client.traits.ConfigurationTrait<MetricsQueryClientBuilder>
      Parameters:
      configuration - the configuration value.
      Returns:
      the MetricsClientBuilder.
    • httpLogOptions

      public MetricsQueryClientBuilder httpLogOptions(com.azure.core.http.policy.HttpLogOptions httpLogOptions)
      Sets The logging configuration for HTTP requests and responses.
      Specified by:
      httpLogOptions in interface com.azure.core.client.traits.HttpTrait<MetricsQueryClientBuilder>
      Parameters:
      httpLogOptions - the httpLogOptions value.
      Returns:
      the MetricsClientBuilder.
    • retryPolicy

      public MetricsQueryClientBuilder retryPolicy(com.azure.core.http.policy.RetryPolicy retryPolicy)
      Sets The retry policy that will attempt to retry failed requests, if applicable.
      Parameters:
      retryPolicy - the retryPolicy value.
      Returns:
      the MetricsClientBuilder.
    • retryOptions

      public MetricsQueryClientBuilder retryOptions(com.azure.core.http.policy.RetryOptions retryOptions)
      Sets the RetryOptions used for creating the client.
      Specified by:
      retryOptions in interface com.azure.core.client.traits.HttpTrait<MetricsQueryClientBuilder>
      Parameters:
      retryOptions - The RetryOptions.
      Returns:
      the updated MetricsQueryClientBuilder.
    • addPolicy

      public MetricsQueryClientBuilder addPolicy(com.azure.core.http.policy.HttpPipelinePolicy customPolicy)
      Adds a custom Http pipeline policy.
      Specified by:
      addPolicy in interface com.azure.core.client.traits.HttpTrait<MetricsQueryClientBuilder>
      Parameters:
      customPolicy - The custom Http pipeline policy to add.
      Returns:
      the MetricsClientBuilder.
    • credential

      public MetricsQueryClientBuilder credential(com.azure.core.credential.TokenCredential tokenCredential)
      Sets The TokenCredential used for authentication.
      Specified by:
      credential in interface com.azure.core.client.traits.TokenCredentialTrait<MetricsQueryClientBuilder>
      Parameters:
      tokenCredential - the tokenCredential value.
      Returns:
      the MetricsClientBuilder.
    • clientOptions

      public MetricsQueryClientBuilder clientOptions(com.azure.core.util.ClientOptions clientOptions)
      Set the ClientOptions used for creating the client.
      Specified by:
      clientOptions in interface com.azure.core.client.traits.HttpTrait<MetricsQueryClientBuilder>
      Parameters:
      clientOptions - The ClientOptions.
      Returns:
      the MetricsQueryClientBuilder
    • serviceVersion

      public MetricsQueryClientBuilder serviceVersion(MetricsQueryServiceVersion serviceVersion)
      The service version to use when creating the client.
      Parameters:
      serviceVersion - The MetricsQueryServiceVersion.
      Returns:
      the MetricsQueryClientBuilder
    • buildClient

      public MetricsQueryClient buildClient()
      Creates a synchronous client with the configured options in this builder.
      Returns:
      A synchronous MetricsQueryClient.
    • buildAsyncClient

      public MetricsQueryAsyncClient buildAsyncClient()
      Creates an asynchronous client with the configured options in this builder.
      Returns:
      An asynchronous MetricsQueryAsyncClient.