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
.GetsMetricsOptions
setApplicationId
(String applicationId) Sets the application ID.setHeaders
(Iterable<Header> headers) Sets theHeaders
.setMetricsOptions
(MetricsOptions metricsOptions) SetsMetricsOptions
that are applied to each metric reported by the client.
-
Constructor Details
-
ClientOptions
public ClientOptions()
-
-
Method Details
-
getApplicationId
Gets the application ID.- Returns:
- The application ID.
-
setApplicationId
Sets the application ID.The
applicationId
is used to configureUserAgentPolicy
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
- IfapplicationId
contains spaces or is larger than 24 characters in length.
-
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
ClientOptions
object.
-
getHeaders
Gets theHeaders
.- Returns:
- The
Headers
, if headers weren't set previously an empty list is returned.
-
setMetricsOptions
SetsMetricsOptions
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 ofMetricsOptions
to set.- Returns:
- The updated
ClientOptions
object.
-
getMetricsOptions
GetsMetricsOptions
- Returns:
- The
MetricsOptions
instance, if metric options weren't set previously,null
is returned.
-