Skip to content

Commit

Permalink
Communication Services - Chat: preview5 final touches (Azure#20028)
Browse files Browse the repository at this point in the history
* final touches
* test sessions
* rename
  • Loading branch information
danielgerlag authored Mar 23, 2021
1 parent bd9f857 commit 33dc698
Show file tree
Hide file tree
Showing 102 changed files with 3,980 additions and 4,045 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* The versions of Chat Service supported by this client library.
*/
public enum ChatServiceVersion implements ServiceVersion {
V2021_03_01_PREVIEW5("2021-03-01-preview5");
V2021_03_07("2021-03-07");

private final String version;

Expand All @@ -34,6 +34,6 @@ public String getVersion() {
*/
public static ChatServiceVersion getLatest() {

return V2021_03_01_PREVIEW5;
return V2021_03_07;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,12 @@ Mono<Response<Void>> updateTopic(String topic, Context context) {
* @return the result.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Void> addParticipants(Iterable<ChatParticipant> participants) {
public Mono<AddChatParticipantsResult> addParticipants(Iterable<ChatParticipant> participants) {
try {
Objects.requireNonNull(participants, "'participants' cannot be null.");
return withContext(context -> addParticipants(participants, context)
.flatMap((Response<AddChatParticipantsResult> res) -> {
return Mono.empty();
return Mono.just(res.getValue());
}));
} catch (RuntimeException ex) {
return monoError(logger, ex);
Expand Down Expand Up @@ -195,8 +195,9 @@ public Mono<Response<AddChatParticipantsResult>> addParticipantsWithResponse(Ite
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Void> addParticipant(ChatParticipant participant) {
return withContext(context -> {
addParticipantWithResponse(participant, context);
return Mono.empty();
return addParticipantWithResponse(participant, context).flatMap(resp -> {
return Mono.empty();
});
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@ public Response<Void> updateTopicWithResponse(String topic, Context context) {
* @param participants Collection of participants to add.
* @throws ChatErrorResponseException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return AddChatParticipantsResult.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public void addParticipants(Iterable<ChatParticipant> participants) {

this.client.addParticipants(participants).block();
public AddChatParticipantsResult addParticipants(Iterable<ChatParticipant> participants) {
return this.client.addParticipants(participants).block();
}

/**
Expand All @@ -103,7 +103,7 @@ public void addParticipants(Iterable<ChatParticipant> participants) {
* @param context The context to associate with this operation.
* @throws ChatErrorResponseException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the completion.
* @return the response.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<AddChatParticipantsResult> addParticipantsWithResponse(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,24 +90,27 @@ public ChatsImpl getChats() {
* Initializes an instance of AzureCommunicationChatService client.
*
* @param endpoint The endpoint of the Azure Communication resource.
* @param apiVersion Api Version.
*/
AzureCommunicationChatServiceImpl(String endpoint) {
AzureCommunicationChatServiceImpl(String endpoint, String apiVersion) {
this(
new HttpPipelineBuilder()
.policies(new UserAgentPolicy(), new RetryPolicy(), new CookiePolicy())
.build(),
JacksonAdapter.createDefaultSerializerAdapter(),
endpoint);
endpoint,
apiVersion);
}

/**
* Initializes an instance of AzureCommunicationChatService client.
*
* @param httpPipeline The HTTP pipeline to send requests through.
* @param endpoint The endpoint of the Azure Communication resource.
* @param apiVersion Api Version.
*/
AzureCommunicationChatServiceImpl(HttpPipeline httpPipeline, String endpoint) {
this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint);
AzureCommunicationChatServiceImpl(HttpPipeline httpPipeline, String endpoint, String apiVersion) {
this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, apiVersion);
}

/**
Expand All @@ -116,12 +119,14 @@ public ChatsImpl getChats() {
* @param httpPipeline The HTTP pipeline to send requests through.
* @param serializerAdapter The serializer to serialize an object into a string.
* @param endpoint The endpoint of the Azure Communication resource.
* @param apiVersion Api Version.
*/
AzureCommunicationChatServiceImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) {
AzureCommunicationChatServiceImpl(
HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint, String apiVersion) {
this.httpPipeline = httpPipeline;
this.serializerAdapter = serializerAdapter;
this.endpoint = endpoint;
this.apiVersion = "2021-03-01-preview5";
this.apiVersion = apiVersion;
this.chatThreads = new ChatThreadsImpl(this);
this.chats = new ChatsImpl(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,22 @@ public AzureCommunicationChatServiceImplBuilder endpoint(String endpoint) {
return this;
}

/*
* Api Version
*/
private String apiVersion;

/**
* Sets Api Version.
*
* @param apiVersion the apiVersion value.
* @return the AzureCommunicationChatServiceImplBuilder.
*/
public AzureCommunicationChatServiceImplBuilder apiVersion(String apiVersion) {
this.apiVersion = apiVersion;
return this;
}

/*
* The HTTP pipeline to send requests through
*/
Expand Down Expand Up @@ -173,14 +189,17 @@ public AzureCommunicationChatServiceImplBuilder addPolicy(HttpPipelinePolicy cus
* @return an instance of AzureCommunicationChatServiceImpl.
*/
public AzureCommunicationChatServiceImpl buildClient() {
if (apiVersion == null) {
this.apiVersion = "2021-03-07";
}
if (pipeline == null) {
this.pipeline = createHttpPipeline();
}
if (serializerAdapter == null) {
this.serializerAdapter = JacksonAdapter.createDefaultSerializerAdapter();
}
AzureCommunicationChatServiceImpl client =
new AzureCommunicationChatServiceImpl(pipeline, serializerAdapter, endpoint);
new AzureCommunicationChatServiceImpl(pipeline, serializerAdapter, endpoint, apiVersion);
return client;
}

Expand Down
Loading

0 comments on commit 33dc698

Please sign in to comment.