Class ChatClientBuilder
- All Implemented Interfaces:
com.azure.core.client.traits.ConfigurationTrait<ChatClientBuilder>,com.azure.core.client.traits.EndpointTrait<ChatClientBuilder>,com.azure.core.client.traits.HttpTrait<ChatClientBuilder>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddPolicy(com.azure.core.http.policy.HttpPipelinePolicy customPolicy) Adds apipeline policyto apply on each request sent.Create asynchronous chat client applying CommunicationTokenCredential, UserAgentPolicy, RetryPolicy, and CookiePolicy.Create synchronous chat client applying CommunicationTokenCredential, UserAgentPolicy, RetryPolicy, and CookiePolicy.clientOptions(com.azure.core.util.ClientOptions clientOptions) Allows for setting common properties such as application ID, headers, proxy configuration, etc.configuration(com.azure.core.util.Configuration configuration) Sets the configuration object used to retrieve environment configuration values during building of the client.credential(com.azure.communication.common.CommunicationTokenCredential communicationTokenCredential) Set a token credential for authorizationSet endpoint of the servicehttpClient(com.azure.core.http.HttpClient httpClient) Sets theHttpClientto use for sending and receiving requests to and from the service.httpLogOptions(com.azure.core.http.policy.HttpLogOptions logOptions) Sets thelogging configurationto use when sending and receiving requests to and from the service.pipeline(com.azure.core.http.HttpPipeline httpPipeline) Sets theHttpPipelineto use for the service client.retryOptions(com.azure.core.http.policy.RetryOptions retryOptions) Sets theRetryOptionsfor all the requests made through the client.retryPolicy(com.azure.core.http.policy.RetryPolicy retryPolicy) Sets theHttpPipelinePolicythat will attempt to retry requests when needed.serviceVersion(ChatServiceVersion version) Sets theChatServiceVersionthat is used when making API requests.
-
Constructor Details
-
ChatClientBuilder
public ChatClientBuilder()
-
-
Method Details
-
endpoint
Set endpoint of the service- Specified by:
endpointin interfacecom.azure.core.client.traits.EndpointTrait<ChatClientBuilder>- Parameters:
endpoint- url of the service- Returns:
- the updated ChatClientBuilder object
-
httpClient
Sets theHttpClientto use for sending and receiving requests to and from the service.Note: It is important to understand the precedence order of the HttpTrait APIs. In particular, if a
HttpPipelineis specified, this takes precedence over all other APIs in the trait, and they will be ignored. If noHttpPipelineis specified, a HTTP pipeline will be constructed internally based on the settings provided to this trait. Additionally, there may be other APIs in types that implement this trait that are also ignored if anHttpPipelineis specified, so please be sure to refer to the documentation of types that implement this trait to understand the full set of implications.- Specified by:
httpClientin interfacecom.azure.core.client.traits.HttpTrait<ChatClientBuilder>- Parameters:
httpClient- TheHttpClientto use for requests.- Returns:
- the updated ChatClientBuilder object
-
credential
public ChatClientBuilder credential(com.azure.communication.common.CommunicationTokenCredential communicationTokenCredential) Set a token credential for authorization- Parameters:
communicationTokenCredential- valid token credential as a string- Returns:
- the updated ChatClientBuilder object
-
clientOptions
Allows for setting common properties such as application ID, headers, proxy configuration, etc. Note that it is recommended that this method be called with an instance of theHttpClientOptionsclass (a subclass of theClientOptionsbase class). The HttpClientOptions subclass provides more configuration options suitable for HTTP clients, which is applicable for any class that implements this HttpTrait interface.Note: It is important to understand the precedence order of the HttpTrait APIs. In particular, if a
HttpPipelineis specified, this takes precedence over all other APIs in the trait, and they will be ignored. If noHttpPipelineis specified, a HTTP pipeline will be constructed internally based on the settings provided to this trait. Additionally, there may be other APIs in types that implement this trait that are also ignored if anHttpPipelineis specified, so please be sure to refer to the documentation of types that implement this trait to understand the full set of implications.- Specified by:
clientOptionsin interfacecom.azure.core.client.traits.HttpTrait<ChatClientBuilder>- Parameters:
clientOptions- A configured instance ofHttpClientOptions.- Returns:
- The updated ChatClientBuilder object.
- See Also:
-
HttpClientOptions
-
addPolicy
Adds apipeline policyto apply on each request sent.Note: It is important to understand the precedence order of the HttpTrait APIs. In particular, if a
HttpPipelineis specified, this takes precedence over all other APIs in the trait, and they will be ignored. If noHttpPipelineis specified, a HTTP pipeline will be constructed internally based on the settings provided to this trait. Additionally, there may be other APIs in types that implement this trait that are also ignored if anHttpPipelineis specified, so please be sure to refer to the documentation of types that implement this trait to understand the full set of implications.- Specified by:
addPolicyin interfacecom.azure.core.client.traits.HttpTrait<ChatClientBuilder>- Parameters:
customPolicy- Apipeline policy.- Returns:
- the updated ChatClientBuilder object
- Throws:
NullPointerException- IfpipelinePolicyisnull.
-
retryPolicy
Sets theHttpPipelinePolicythat will attempt to retry requests when needed.A default retry policy will be supplied if one isn't provided.
Setting this is mutually exclusive with using
retryOptions(RetryOptions).- Parameters:
retryPolicy- TheRetryPolicythat will attempt to retry requests when needed.- Returns:
- The updated ChatClientBuilder object.
-
retryOptions
Sets theRetryOptionsfor all the requests made through the client.Note: It is important to understand the precedence order of the HttpTrait APIs. In particular, if a
HttpPipelineis specified, this takes precedence over all other APIs in the trait, and they will be ignored. If noHttpPipelineis specified, a HTTP pipeline will be constructed internally based on the settings provided to this trait. Additionally, there may be other APIs in types that implement this trait that are also ignored if anHttpPipelineis specified, so please be sure to refer to the documentation of types that implement this trait to understand the full set of implications.Setting this is mutually exclusive with using
retryPolicy(RetryPolicy).- Specified by:
retryOptionsin interfacecom.azure.core.client.traits.HttpTrait<ChatClientBuilder>- Parameters:
retryOptions- TheRetryOptionsto use for all the requests made through the client.- Returns:
- The updated ChatClientBuilder object.
-
httpLogOptions
Sets thelogging configurationto use when sending and receiving requests to and from the service. If alogLevelis not provided, default value ofHttpLogDetailLevel.NONEis set.Note: It is important to understand the precedence order of the HttpTrait APIs. In particular, if a
HttpPipelineis specified, this takes precedence over all other APIs in the trait, and they will be ignored. If noHttpPipelineis specified, a HTTP pipeline will be constructed internally based on the settings provided to this trait. Additionally, there may be other APIs in types that implement this trait that are also ignored if anHttpPipelineis specified, so please be sure to refer to the documentation of types that implement this trait to understand the full set of implications.- Specified by:
httpLogOptionsin interfacecom.azure.core.client.traits.HttpTrait<ChatClientBuilder>- Parameters:
logOptions- Thelogging configurationto use when sending and receiving requests to and from the service.- Returns:
- the updated ChatClientBuilder object
-
serviceVersion
Sets theChatServiceVersionthat 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-ChatServiceVersionof the service to be used when making requests.- Returns:
- the updated ChatClientBuilder object
-
pipeline
Sets theHttpPipelineto use for the service client.Note: It is important to understand the precedence order of the HttpTrait APIs. In particular, if a
IfHttpPipelineis specified, this takes precedence over all other APIs in the trait, and they will be ignored. If noHttpPipelineis specified, a HTTP pipeline will be constructed internally based on the settings provided to this trait. Additionally, there may be other APIs in types that implement this trait that are also ignored if anHttpPipelineis specified, so please be sure to refer to the documentation of types that implement this trait to understand the full set of implications.pipelineis set, all other settings are ignored, aside fromendpoint.- Specified by:
pipelinein interfacecom.azure.core.client.traits.HttpTrait<ChatClientBuilder>- Parameters:
httpPipeline-HttpPipelineto use for sending service requests and receiving responses.- Returns:
- the updated ChatClientBuilder object
-
configuration
Sets the configuration object used to retrieve environment configuration values during building of the client.- Specified by:
configurationin interfacecom.azure.core.client.traits.ConfigurationTrait<ChatClientBuilder>- Parameters:
configuration- Configuration store used to retrieve environment configurations.- Returns:
- the updated ChatClientBuilder object
-
buildClient
Create synchronous chat client applying CommunicationTokenCredential, UserAgentPolicy, RetryPolicy, and CookiePolicy. Additional HttpPolicies specified by additionalPolicies will be applied after them- Returns:
- ChatClient instance
- Throws:
IllegalStateException- If bothretryOptions(RetryOptions)andretryPolicy(RetryPolicy)have been set.
-
buildAsyncClient
Create asynchronous chat client applying CommunicationTokenCredential, UserAgentPolicy, RetryPolicy, and CookiePolicy. Additional HttpPolicies specified by additionalPolicies will be applied after them- Returns:
- ChatAsyncClient instance
- Throws:
IllegalStateException- If bothretryOptions(RetryOptions)andretryPolicy(RetryPolicy)have been set.
-