Package com.azure.maps.traffic
Class TrafficClientBuilder
java.lang.Object
com.azure.maps.traffic.TrafficClientBuilder
- All Implemented Interfaces:
com.azure.core.client.traits.AzureKeyCredentialTrait<TrafficClientBuilder>
,com.azure.core.client.traits.ConfigurationTrait<TrafficClientBuilder>
,com.azure.core.client.traits.EndpointTrait<TrafficClientBuilder>
,com.azure.core.client.traits.HttpTrait<TrafficClientBuilder>
,com.azure.core.client.traits.TokenCredentialTrait<TrafficClientBuilder>
public final class TrafficClientBuilder
extends Object
implements com.azure.core.client.traits.AzureKeyCredentialTrait<TrafficClientBuilder>, com.azure.core.client.traits.TokenCredentialTrait<TrafficClientBuilder>, com.azure.core.client.traits.HttpTrait<TrafficClientBuilder>, com.azure.core.client.traits.ConfigurationTrait<TrafficClientBuilder>, com.azure.core.client.traits.EndpointTrait<TrafficClientBuilder>
A builder for creating a new instance of the TrafficClient type.
Builder class used to instantiate both synchronous and asynchronous
TrafficClient
clients.
Example usage
Creating a sync client using aAzureKeyCredential
:
// Authenticates using subscription key AzureKeyCredential keyCredential = new AzureKeyCredential(System.getenv("SUBSCRIPTION_KEY")); // Creates a builder TrafficClientBuilder builder = new TrafficClientBuilder(); builder.credential(keyCredential); builder.httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BODY_AND_HEADERS)); // Builds the client TrafficClient client = builder.buildClient();
-
Constructor Summary
ConstructorDescriptionDefault constructor for the builder class; Create an instance of the TrafficClientBuilder. -
Method Summary
Modifier and TypeMethodDescriptionaddPolicy
(com.azure.core.http.policy.HttpPipelinePolicy customPolicy) Adds a custom Http pipeline policy.Builds an instance of SearchAsyncClient async client.Builds an instance of SearchClient sync client.clientOptions
(com.azure.core.util.ClientOptions clientOptions) Sets The client options such as application ID and custom headers to set on a request.configuration
(com.azure.core.util.Configuration configuration) Sets The configuration store that is used during construction of the service client.credential
(com.azure.core.credential.AzureKeyCredential keyCredential) Sets theAzureKeyCredential
used to authenticate HTTP requests.credential
(com.azure.core.credential.TokenCredential tokenCredential) Sets theTokenCredential
used to authenticate HTTP requests.Set endpoint of the service.httpClient
(com.azure.core.http.HttpClient httpClient) Sets The HTTP client used to send the request.httpLogOptions
(com.azure.core.http.policy.HttpLogOptions httpLogOptions) Sets The logging configuration for HTTP requests and responses.pipeline
(com.azure.core.http.HttpPipeline pipeline) Sets The HTTP pipeline to send requests through.retryOptions
(com.azure.core.http.policy.RetryOptions retryOptions) Sets retry optionsretryPolicy
(com.azure.core.http.policy.RetryPolicy retryPolicy) Sets The retry policy that will attempt to retry failed requests, if applicable.serviceVersion
(TrafficServiceVersion version) Sets theTrafficServiceVersion
that is used when making API requests.trafficClientId
(String trafficClientId) Sets the Azure Maps client id for use with Azure AD Authentication.
-
Constructor Details
-
TrafficClientBuilder
public TrafficClientBuilder()Default constructor for the builder class; Create an instance of the TrafficClientBuilder.
-
-
Method Details
-
trafficClientId
Sets the Azure Maps client id for use with Azure AD Authentication. This client id is the account-based GUID that appears on the Azure Maps Authentication page. More details: Azure Maps AD Authentication- Parameters:
trafficClientId
- the clientId value.- Returns:
- the SearchClientBuilder.
-
endpoint
Set endpoint of the service.- Specified by:
endpoint
in interfacecom.azure.core.client.traits.EndpointTrait<TrafficClientBuilder>
- Parameters:
endpoint
- url of the service- Returns:
- TrafficClientBuilder
-
serviceVersion
Sets theTrafficServiceVersion
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 of the client library will have the result of potentially moving to a newer service version.
Targeting a specific service version may also mean that the service will return an error for newer APIs.
- Parameters:
version
-TrafficServiceVersion
of the service to be used when making requests.- Returns:
- the updated TrafficClientBuilder object
-
pipeline
Sets The HTTP pipeline to send requests through.- Specified by:
pipeline
in interfacecom.azure.core.client.traits.HttpTrait<TrafficClientBuilder>
- Parameters:
pipeline
- the pipeline value.- Returns:
- the TrafficClientBuilder.
-
httpClient
Sets The HTTP client used to send the request.- Specified by:
httpClient
in interfacecom.azure.core.client.traits.HttpTrait<TrafficClientBuilder>
- Parameters:
httpClient
- the httpClient value.- Returns:
- the TrafficClientBuilder.
-
configuration
Sets The configuration store that is used during construction of the service client.- Specified by:
configuration
in interfacecom.azure.core.client.traits.ConfigurationTrait<TrafficClientBuilder>
- Parameters:
configuration
- the configuration value.- Returns:
- the TrafficClientBuilder.
-
httpLogOptions
public TrafficClientBuilder httpLogOptions(com.azure.core.http.policy.HttpLogOptions httpLogOptions) Sets The logging configuration for HTTP requests and responses.- Specified by:
httpLogOptions
in interfacecom.azure.core.client.traits.HttpTrait<TrafficClientBuilder>
- Parameters:
httpLogOptions
- the httpLogOptions value.- Returns:
- the TrafficClientBuilder.
-
retryPolicy
Sets The retry policy that will attempt to retry failed requests, if applicable.- Parameters:
retryPolicy
- the retryPolicy value.- Returns:
- the TrafficClientBuilder.
-
clientOptions
Sets The client options such as application ID and custom headers to set on a request.- Specified by:
clientOptions
in interfacecom.azure.core.client.traits.HttpTrait<TrafficClientBuilder>
- Parameters:
clientOptions
- the clientOptions value.- Returns:
- the TrafficClientBuilder.
-
addPolicy
Adds a custom Http pipeline policy.- Specified by:
addPolicy
in interfacecom.azure.core.client.traits.HttpTrait<TrafficClientBuilder>
- Parameters:
customPolicy
- The custom Http pipeline policy to add.- Returns:
- the TrafficClientBuilder.
-
credential
Sets theTokenCredential
used to authenticate HTTP requests.- Specified by:
credential
in interfacecom.azure.core.client.traits.TokenCredentialTrait<TrafficClientBuilder>
- Parameters:
tokenCredential
-TokenCredential
used to authenticate HTTP requests.- Returns:
- The updated
TrafficClientBuilder
object. - Throws:
NullPointerException
- IftokenCredential
is null.
-
credential
Sets theAzureKeyCredential
used to authenticate HTTP requests.- Specified by:
credential
in interfacecom.azure.core.client.traits.AzureKeyCredentialTrait<TrafficClientBuilder>
- Parameters:
keyCredential
- TheAzureKeyCredential
used to authenticate HTTP requests.- Returns:
- The updated
TrafficClientBuilder
object. - Throws:
NullPointerException
- IfkeyCredential
is null.
-
retryOptions
Sets retry options- Specified by:
retryOptions
in interfacecom.azure.core.client.traits.HttpTrait<TrafficClientBuilder>
- Parameters:
retryOptions
- the retry options for the client- Returns:
- a reference to this
TrafficClientBuilder
-
buildAsyncClient
Builds an instance of SearchAsyncClient async client.- Returns:
- an instance of SearchAsyncClient.
-
buildClient
Builds an instance of SearchClient sync client.- Returns:
- an instance of SearchClient.
-