Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,13 @@
"old" : ".*? com\\.azure\\.communication\\.callautomation\\.models.*",
"new" : ".*? com\\.azure\\.communication\\.callautomation\\.models.*",
"justification": "Migration to azure-json"
},
{
"regex": true,
"code" : "java\\.annotation\\.removed",
"old" : ".*? com\\.azure\\.communication\\.chat\\.models.*",
"new" : ".*? com\\.azure\\.communication\\.chat\\.models.*",
"justification": "Migration to azure-json"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ Mono<Response<CreateChatThreadResult>> createChatThread(CreateChatThreadOptions
context = context == null ? Context.NONE : context;
try {
return this.chatClient.createChatThreadWithResponseAsync(
CreateChatThreadOptionsConverter.convert(options), options.getIdempotencyToken(), context)
CreateChatThreadOptionsConverter.convert(options), context)
.onErrorMap(CommunicationErrorResponseException.class, e -> translateException(e))
.map(result -> new SimpleResponse<CreateChatThreadResult>(
result, CreateChatThreadResultConverter.convert(result.getValue())));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,22 @@

import com.azure.core.annotation.Generated;
import com.azure.core.annotation.ServiceClientBuilder;
import com.azure.core.client.traits.AzureKeyCredentialTrait;
import com.azure.core.client.traits.ConfigurationTrait;
import com.azure.core.client.traits.EndpointTrait;
import com.azure.core.client.traits.HttpTrait;
import com.azure.core.credential.AzureKeyCredential;
import com.azure.core.http.HttpClient;
import com.azure.core.http.HttpHeaderName;
import com.azure.core.http.HttpHeaders;
import com.azure.core.http.HttpPipeline;
import com.azure.core.http.HttpPipelineBuilder;
import com.azure.core.http.HttpPipelinePosition;
import com.azure.core.http.policy.AddDatePolicy;
import com.azure.core.http.policy.AddHeadersFromContextPolicy;
import com.azure.core.http.policy.AddHeadersPolicy;
import com.azure.core.http.policy.HttpLogOptions;
import com.azure.core.http.policy.AzureKeyCredentialPolicy;
import com.azure.core.http.policy.HttpLoggingPolicy;
import com.azure.core.http.policy.HttpLogOptions;
import com.azure.core.http.policy.HttpPipelinePolicy;
import com.azure.core.http.policy.HttpPolicyProviders;
import com.azure.core.http.policy.RequestIdPolicy;
Expand All @@ -44,6 +46,7 @@
@ServiceClientBuilder(serviceClients = { AzureCommunicationChatServiceImpl.class })
public final class AzureCommunicationChatServiceImplBuilder implements
HttpTrait<AzureCommunicationChatServiceImplBuilder>, ConfigurationTrait<AzureCommunicationChatServiceImplBuilder>,
AzureKeyCredentialTrait<AzureCommunicationChatServiceImplBuilder>,
EndpointTrait<AzureCommunicationChatServiceImplBuilder> {
@Generated
private static final String SDK_NAME = "name";
Expand Down Expand Up @@ -172,6 +175,22 @@ public AzureCommunicationChatServiceImplBuilder configuration(Configuration conf
return this;
}

/*
* The AzureKeyCredential used for authentication.
*/
@Generated
private AzureKeyCredential azureKeyCredential;

/**
* {@inheritDoc}.
*/
@Generated
@Override
public AzureCommunicationChatServiceImplBuilder credential(AzureKeyCredential azureKeyCredential) {
this.azureKeyCredential = azureKeyCredential;
return this;
}

/*
* The service endpoint
*/
Expand Down Expand Up @@ -249,6 +268,7 @@ public AzureCommunicationChatServiceImplBuilder retryPolicy(RetryPolicy retryPol
*/
@Generated
public AzureCommunicationChatServiceImpl buildClient() {
this.validateClient();
HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline();
String localApiVersion = (apiVersion != null) ? apiVersion : "2024-03-07";
SerializerAdapter localSerializerAdapter
Expand All @@ -258,6 +278,13 @@ public AzureCommunicationChatServiceImpl buildClient() {
return client;
}

@Generated
private void validateClient() {
// This method is invoked from 'buildInnerClient'/'buildClient' method.
// Developer can customize this method, to validate that the necessary conditions are met for the new client.
Objects.requireNonNull(endpoint, "'endpoint' cannot be null.");
}

@Generated
private HttpPipeline createHttpPipeline() {
Configuration buildConfiguration
Expand All @@ -271,23 +298,28 @@ private HttpPipeline createHttpPipeline() {
policies.add(new UserAgentPolicy(applicationId, clientName, clientVersion, buildConfiguration));
policies.add(new RequestIdPolicy());
policies.add(new AddHeadersFromContextPolicy());
HttpHeaders headers = new HttpHeaders();
localClientOptions.getHeaders()
.forEach(header -> headers.set(HttpHeaderName.fromString(header.getName()), header.getValue()));
if (headers.getSize() > 0) {
HttpHeaders headers = CoreUtils.createHttpHeadersFromClientOptions(localClientOptions);
if (headers != null) {
policies.add(new AddHeadersPolicy(headers));
}
this.pipelinePolicies.stream().filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_CALL)
this.pipelinePolicies.stream()
.filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_CALL)
.forEach(p -> policies.add(p));
HttpPolicyProviders.addBeforeRetryPolicies(policies);
policies.add(ClientBuilderUtil.validateAndGetRetryPolicy(retryPolicy, retryOptions, new RetryPolicy()));
policies.add(new AddDatePolicy());
this.pipelinePolicies.stream().filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_RETRY)
if (azureKeyCredential != null) {
policies.add(new AzureKeyCredentialPolicy("Authorization", azureKeyCredential));
}
this.pipelinePolicies.stream()
.filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_RETRY)
.forEach(p -> policies.add(p));
HttpPolicyProviders.addAfterRetryPolicies(policies);
policies.add(new HttpLoggingPolicy(httpLogOptions));
policies.add(new HttpLoggingPolicy(localHttpLogOptions));
HttpPipeline httpPipeline = new HttpPipelineBuilder().policies(policies.toArray(new HttpPipelinePolicy[0]))
.httpClient(httpClient).clientOptions(localClientOptions).build();
.httpClient(httpClient)
.clientOptions(localClientOptions)
.build();
return httpPipeline;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2063,9 +2063,7 @@ public void sendTypingNotification(String chatThreadId) {
/**
* Get the next page of items.
*
* @param nextLink The URL to get the next list of items
*
* The nextLink parameter.
* @param nextLink The URL to get the next list of items.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws CommunicationErrorResponseException thrown if the request is rejected by server.
* @throws CommunicationErrorResponseException thrown if the request is rejected by server on status code 401, 403,
Expand All @@ -2087,9 +2085,7 @@ public Mono<PagedResponse<ChatMessageReadReceipt>> listChatReadReceiptsNextSingl
/**
* Get the next page of items.
*
* @param nextLink The URL to get the next list of items
*
* The nextLink parameter.
* @param nextLink The URL to get the next list of items.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws CommunicationErrorResponseException thrown if the request is rejected by server.
Expand All @@ -2111,9 +2107,7 @@ public Mono<PagedResponse<ChatMessageReadReceipt>> listChatReadReceiptsNextSingl
/**
* Get the next page of items.
*
* @param nextLink The URL to get the next list of items
*
* The nextLink parameter.
* @param nextLink The URL to get the next list of items.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws CommunicationErrorResponseException thrown if the request is rejected by server.
* @throws CommunicationErrorResponseException thrown if the request is rejected by server on status code 401, 403,
Expand All @@ -2129,9 +2123,7 @@ public PagedResponse<ChatMessageReadReceipt> listChatReadReceiptsNextSinglePage(
/**
* Get the next page of items.
*
* @param nextLink The URL to get the next list of items
*
* The nextLink parameter.
* @param nextLink The URL to get the next list of items.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws CommunicationErrorResponseException thrown if the request is rejected by server.
Expand All @@ -2148,9 +2140,7 @@ public PagedResponse<ChatMessageReadReceipt> listChatReadReceiptsNextSinglePage(
/**
* Get the next page of items.
*
* @param nextLink The URL to get the next list of items
*
* The nextLink parameter.
* @param nextLink The URL to get the next list of items.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws CommunicationErrorResponseException thrown if the request is rejected by server.
* @throws CommunicationErrorResponseException thrown if the request is rejected by server on status code 401, 403,
Expand All @@ -2171,9 +2161,7 @@ public Mono<PagedResponse<ChatMessage>> listChatMessagesNextSinglePageAsync(Stri
/**
* Get the next page of items.
*
* @param nextLink The URL to get the next list of items
*
* The nextLink parameter.
* @param nextLink The URL to get the next list of items.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws CommunicationErrorResponseException thrown if the request is rejected by server.
Expand All @@ -2194,9 +2182,7 @@ public Mono<PagedResponse<ChatMessage>> listChatMessagesNextSinglePageAsync(Stri
/**
* Get the next page of items.
*
* @param nextLink The URL to get the next list of items
*
* The nextLink parameter.
* @param nextLink The URL to get the next list of items.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws CommunicationErrorResponseException thrown if the request is rejected by server.
* @throws CommunicationErrorResponseException thrown if the request is rejected by server on status code 401, 403,
Expand All @@ -2212,9 +2198,7 @@ public PagedResponse<ChatMessage> listChatMessagesNextSinglePage(String nextLink
/**
* Get the next page of items.
*
* @param nextLink The URL to get the next list of items
*
* The nextLink parameter.
* @param nextLink The URL to get the next list of items.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws CommunicationErrorResponseException thrown if the request is rejected by server.
Expand All @@ -2231,9 +2215,7 @@ public PagedResponse<ChatMessage> listChatMessagesNextSinglePage(String nextLink
/**
* Get the next page of items.
*
* @param nextLink The URL to get the next list of items
*
* The nextLink parameter.
* @param nextLink The URL to get the next list of items.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws CommunicationErrorResponseException thrown if the request is rejected by server.
* @throws CommunicationErrorResponseException thrown if the request is rejected by server on status code 401, 403,
Expand All @@ -2255,9 +2237,7 @@ public Mono<PagedResponse<ChatParticipant>> listChatParticipantsNextSinglePageAs
/**
* Get the next page of items.
*
* @param nextLink The URL to get the next list of items
*
* The nextLink parameter.
* @param nextLink The URL to get the next list of items.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws CommunicationErrorResponseException thrown if the request is rejected by server.
Expand All @@ -2279,9 +2259,7 @@ public Mono<PagedResponse<ChatParticipant>> listChatParticipantsNextSinglePageAs
/**
* Get the next page of items.
*
* @param nextLink The URL to get the next list of items
*
* The nextLink parameter.
* @param nextLink The URL to get the next list of items.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws CommunicationErrorResponseException thrown if the request is rejected by server.
* @throws CommunicationErrorResponseException thrown if the request is rejected by server on status code 401, 403,
Expand All @@ -2297,9 +2275,7 @@ public PagedResponse<ChatParticipant> listChatParticipantsNextSinglePage(String
/**
* Get the next page of items.
*
* @param nextLink The URL to get the next list of items
*
* The nextLink parameter.
* @param nextLink The URL to get the next list of items.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws CommunicationErrorResponseException thrown if the request is rejected by server.
Expand Down
Loading