Class ClientOptions

java.lang.Object
com.azure.core.util.ClientOptions
Direct Known Subclasses:
AmqpClientOptions, HttpClientOptions

public class ClientOptions extends Object
General configuration options for clients.
  • Constructor Details

    • ClientOptions

      public ClientOptions()
  • Method Details

    • getApplicationId

      public String getApplicationId()
      Gets the application ID.
      Returns:
      The application ID.
    • setApplicationId

      public ClientOptions setApplicationId(String applicationId)
      Sets the application ID.

      The applicationId is used to configure UserAgentPolicy for telemetry/monitoring purposes.

      See Azure Core: Telemetry policy for additional information.

      Code Samples

      Create ClientOptions with application ID 'myApplicationId'

       ClientOptions clientOptions = new ClientOptions()
           .setApplicationId("myApplicationId");
       
      Parameters:
      applicationId - The application ID.
      Returns:
      The updated ClientOptions object.
      Throws:
      IllegalArgumentException - If applicationId contains spaces or is larger than 24 characters in length.
    • setHeaders

      public ClientOptions setHeaders(Iterable<Header> headers)
      Sets the Headers.

      The passed headers are applied to each request sent with the client.

      This overwrites all previously set headers.

      Code Samples

      Create ClientOptions with Header 'myCustomHeader':'myStaticValue'

       ClientOptions clientOptions = new ClientOptions()
           .setHeaders(Collections.singletonList(new Header("myCustomHeader", "myStaticValue")));
       
      Parameters:
      headers - The headers.
      Returns:
      The updated ClientOptions object.
    • getHeaders

      public Iterable<Header> getHeaders()
      Gets the Headers.
      Returns:
      The Headers, if headers weren't set previously an empty list is returned.
    • setMetricsOptions

      public ClientOptions setMetricsOptions(MetricsOptions metricsOptions)
      Sets MetricsOptions that are applied to each metric reported by the client. Use metrics options to enable and disable metrics or pass implementation-specific configuration.
      Parameters:
      metricsOptions - instance of MetricsOptions to set.
      Returns:
      The updated ClientOptions object.
    • getMetricsOptions

      public MetricsOptions getMetricsOptions()
      Returns:
      The MetricsOptions instance, if metric options weren't set previously, null is returned.