Package com.azure.core.util
Class ClientOptions
java.lang.Object
com.azure.core.util.ClientOptions
- Direct Known Subclasses:
HttpClientOptions
General configuration options for clients.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGets the application ID.Gets theHeaders.GetsMetricsOptionsGetsTracingOptionssetApplicationId(String applicationId) Sets the application ID.setHeaders(Iterable<Header> headers) Sets theHeaders.setMetricsOptions(MetricsOptions metricsOptions) SetsMetricsOptionsthat are applied to each metric reported by the client.setTracingOptions(TracingOptions tracingOptions) SetsTracingOptionsthat are applied to each tracing reported by the client.
-
Constructor Details
-
ClientOptions
public ClientOptions()Creates a new instance ofClientOptions.
-
-
Method Details
-
getApplicationId
Gets the application ID.- Returns:
- The application ID.
-
setApplicationId
Sets the application ID.The
applicationIdis used to configureUserAgentPolicyfor 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- IfapplicationIdcontains spaces.
-
setHeaders
Sets theHeaders.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
ClientOptionsobject.
-
getHeaders
Gets theHeaders.- Returns:
- The
Headers, if headers weren't set previously an empty list is returned.
-
setMetricsOptions
SetsMetricsOptionsthat 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 ofMetricsOptionsto set.- Returns:
- The updated
ClientOptionsobject.
-
getMetricsOptions
GetsMetricsOptions- Returns:
- The
MetricsOptionsinstance, if metrics options weren't set previously,nullis returned.
-
setTracingOptions
SetsTracingOptionsthat are applied to each tracing reported by the client. Use tracing options to enable and disable tracing or pass implementation-specific configuration.- Parameters:
tracingOptions- instance ofTracingOptionsto set.- Returns:
- The updated
ClientOptionsobject.
-
getTracingOptions
GetsTracingOptions- Returns:
- The
TracingOptionsinstance, if tracing options weren't set previously,nullis returned.
-