Skip to content
Closed
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
2 changes: 1 addition & 1 deletion eng/versioning/version_client.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ com.azure:azure-communication-chat;1.6.8;1.7.0-beta.1
com.azure:azure-communication-common;1.4.8;1.5.0-beta.1
com.azure:azure-communication-common-perf;1.0.0-beta.1;1.0.0-beta.1
com.azure:azure-communication-email;1.1.5;1.2.0-beta.2
com.azure:azure-communication-identity;1.6.13;1.7.0-beta.1
com.azure:azure-communication-identity;1.6.13;2.0.0
com.azure:azure-communication-jobrouter;1.1.21;2.0.0-beta.1
com.azure:azure-communication-messages;1.1.12;1.2.0-beta.2
com.azure:azure-communication-phonenumbers;1.4.6;1.5.0-beta.1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
# Release History

## 1.7.0-beta.1 (Unreleased)
## 2.0.0 (Unreleased)

### Features Added

- Added support for service version `2026-09-23`, which is now the default. Select it explicitly
with `CommunicationIdentityServiceVersion.V2026_09_23`.

### Breaking Changes

### Bugs Fixed
Expand Down
43 changes: 42 additions & 1 deletion sdk/communication/azure-communication-identity/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<groupId>com.azure</groupId>
<artifactId>azure-communication-identity</artifactId>
<packaging>jar</packaging>
<version>1.7.0-beta.1</version> <!-- {x-version-update;com.azure:azure-communication-identity;current} -->
<version>2.0.0</version> <!-- {x-version-update;com.azure:azure-communication-identity;current} -->

<name>Microsoft Azure identity client library for communication</name>
<description>
Expand Down Expand Up @@ -96,4 +96,45 @@
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<!--
The coverage gate measures the code this library hands to customers: the convenience layer,
the error converter, and the public models. The emitter also produces a complete protocol
client for every operation group in the spec - a builder, a synchronous and an asynchronous
client per group, and the wire models behind them. None of that is reachable through the
public API, so no test can exercise it, and counting it measures the size of the spec rather
than the quality of this library.

CommunicationTokenScope and GetTokenForTeamsUserOptions are generated but are part of the
published surface, so they are deliberately not excluded.
-->
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.15</version> <!-- {x-version-update;org.jacoco:jacoco-maven-plugin;external_dependency} -->
<executions>
<execution>
<id>check</id>
<configuration>
<excludes>
<exclude>**/com/azure/communication/identity/IdentityClientBuilder*</exclude>
<exclude>**/com/azure/communication/identity/IdentityOperations*Client*</exclude>
<exclude>**/com/azure/communication/identity/IdentityServiceVersion*</exclude>
<exclude>**/com/azure/communication/identity/TeamsExtensionOperations*Client*</exclude>
<exclude>**/com/azure/communication/identity/TeamsUserOperations*Client*</exclude>
<exclude>**/com/azure/communication/identity/implementation/IdentityClientImpl*</exclude>
<exclude>**/com/azure/communication/identity/implementation/IdentityOperationsImpl*</exclude>
<exclude>**/com/azure/communication/identity/implementation/TeamsExtensionOperationsImpl*</exclude>
<exclude>**/com/azure/communication/identity/implementation/TeamsUserOperationsImpl*</exclude>
<exclude>**/com/azure/communication/identity/implementation/models/CommunicationIdentity*</exclude>
<exclude>**/com/azure/communication/identity/implementation/models/TeamsExtension*</exclude>
</excludes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@

package com.azure.communication.identity;

import com.azure.communication.identity.implementation.CommunicationIdentitiesImpl;
import com.azure.communication.identity.implementation.CommunicationIdentityClientImpl;
import com.azure.communication.identity.implementation.IdentityClientImpl;
import com.azure.communication.identity.implementation.converters.IdentityErrorConverter;
import com.azure.communication.identity.implementation.models.CommunicationErrorResponseException;
import com.azure.communication.identity.implementation.models.CommunicationIdentityAccessTokenRequest;
Expand All @@ -19,8 +18,11 @@
import com.azure.core.annotation.ServiceClient;
import com.azure.core.annotation.ServiceMethod;
import com.azure.core.credential.AccessToken;
import com.azure.core.http.HttpHeaderName;
import com.azure.core.http.rest.RequestOptions;
import com.azure.core.http.rest.Response;
import com.azure.core.http.rest.SimpleResponse;
import com.azure.core.util.BinaryData;
import com.azure.core.util.logging.ClientLogger;

import java.time.Duration;
Expand Down Expand Up @@ -56,11 +58,47 @@
@ServiceClient(builder = CommunicationIdentityClientBuilder.class, isAsync = true)
public final class CommunicationIdentityAsyncClient {

private final CommunicationIdentitiesImpl client;
private final IdentityOperationsAsyncClient client;
private final TeamsUserOperationsAsyncClient teamsUserClient;
private final ClientLogger logger = new ClientLogger(CommunicationIdentityAsyncClient.class);

CommunicationIdentityAsyncClient(CommunicationIdentityClientImpl communicationIdentityServiceClient) {
client = communicationIdentityServiceClient.getCommunicationIdentities();
CommunicationIdentityAsyncClient(IdentityClientImpl identityClient) {
client = new IdentityOperationsAsyncClient(identityClient.getIdentityOperations());
teamsUserClient = new TeamsUserOperationsAsyncClient(identityClient.getTeamsUserOperations());
}

/**
* Builds {@link RequestOptions} for the operations that return no content.
*
* <p>The generated protocol methods for {@code delete} and {@code revokeAccessTokens} declare no
* Accept header, because those operations respond 204 with no body, so azure-core falls back to
* the wildcard. The AutoRest-generated client this replaces sent {@code application/json} on
* every operation regardless of response shape. Setting it here keeps the bytes on the wire
* unchanged for existing callers.</p>
*/
private static RequestOptions noContentRequestOptions() {
return new RequestOptions().setHeader(HttpHeaderName.ACCEPT, "application/json");
}

/**
* Deserializes the {@link BinaryData} body returned by a generated protocol method, preserving the
* status code and headers of the original response.
*/
private static <T> Response<T> mapResponse(Response<BinaryData> response, Class<T> type) {
BinaryData value = response.getValue();
return new SimpleResponse<>(response, value == null ? null : value.toObject(type));
}

/**
* Calls the generated create protocol method. The request body is carried on {@link RequestOptions}
* because the generated signature takes no body parameter.
*/
private Mono<Response<CommunicationIdentityAccessTokenResult>>
createWithResponseInternal(CommunicationIdentityCreateRequest body) {
RequestOptions requestOptions = new RequestOptions();
requestOptions.setBody(BinaryData.fromObject(body));
return client.createWithResponse(requestOptions)
.map(response -> mapResponse(response, CommunicationIdentityAccessTokenResult.class));
}

/**
Expand All @@ -71,7 +109,7 @@ public final class CommunicationIdentityAsyncClient {
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<CommunicationUserIdentifier> createUser() {
try {
return client.createAsync(new CommunicationIdentityCreateRequest())
return client.create(new CommunicationIdentityCreateRequest())
.onErrorMap(CommunicationErrorResponseException.class, IdentityErrorConverter::translateException)
.flatMap((CommunicationIdentityAccessTokenResult result) -> {
return Mono.just(new CommunicationUserIdentifier(result.getIdentity().getId()));
Expand All @@ -89,7 +127,7 @@ public Mono<CommunicationUserIdentifier> createUser() {
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<CommunicationUserIdentifier>> createUserWithResponse() {
try {
return client.createWithResponseAsync(new CommunicationIdentityCreateRequest())
return createWithResponseInternal(new CommunicationIdentityCreateRequest())
.onErrorMap(CommunicationErrorResponseException.class, IdentityErrorConverter::translateException)
.flatMap((Response<CommunicationIdentityAccessTokenResult> response) -> {
String id = response.getValue().getIdentity().getId();
Expand Down Expand Up @@ -118,7 +156,7 @@ public Mono<CommunicationUserIdentifierAndToken> createUserAndToken(Iterable<Com
CommunicationIdentityCreateRequest communicationIdentityCreateRequest = CommunicationIdentityClientUtils
.createCommunicationIdentityCreateRequest(scopes, tokenExpiresIn, logger);

return client.createAsync(communicationIdentityCreateRequest)
return client.create(communicationIdentityCreateRequest)
.onErrorMap(CommunicationErrorResponseException.class, IdentityErrorConverter::translateException)
.flatMap((CommunicationIdentityAccessTokenResult result) -> {
return Mono.just(userWithAccessTokenResultConverter(result));
Expand Down Expand Up @@ -156,7 +194,7 @@ public Mono<CommunicationUserIdentifierAndToken> createUserAndToken(Iterable<Com
CommunicationIdentityCreateRequest communicationIdentityCreateRequest = CommunicationIdentityClientUtils
.createCommunicationIdentityCreateRequest(scopes, tokenExpiresIn, logger);

return client.createWithResponseAsync(communicationIdentityCreateRequest)
return createWithResponseInternal(communicationIdentityCreateRequest)
.onErrorMap(CommunicationErrorResponseException.class, IdentityErrorConverter::translateException)
.flatMap((Response<CommunicationIdentityAccessTokenResult> response) -> {
return Mono.just(new SimpleResponse<CommunicationUserIdentifierAndToken>(response,
Expand Down Expand Up @@ -190,7 +228,8 @@ public Mono<CommunicationUserIdentifierAndToken> createUserAndToken(Iterable<Com
public Mono<Void> deleteUser(CommunicationUserIdentifier communicationUser) {
try {
Objects.requireNonNull(communicationUser);
return client.deleteAsync(communicationUser.getId())
return client.deleteWithResponse(communicationUser.getId(), noContentRequestOptions())
.then()
.onErrorMap(CommunicationErrorResponseException.class, IdentityErrorConverter::translateException);
} catch (RuntimeException ex) {
return monoError(logger, ex);
Expand All @@ -208,7 +247,7 @@ public Mono<Void> deleteUser(CommunicationUserIdentifier communicationUser) {
public Mono<Response<Void>> deleteUserWithResponse(CommunicationUserIdentifier communicationUser) {
try {
Objects.requireNonNull(communicationUser);
return client.deleteWithResponseAsync(communicationUser.getId())
return client.deleteWithResponse(communicationUser.getId(), noContentRequestOptions())
.onErrorMap(CommunicationErrorResponseException.class, IdentityErrorConverter::translateException);
} catch (RuntimeException ex) {
return monoError(logger, ex);
Expand All @@ -225,7 +264,8 @@ public Mono<Response<Void>> deleteUserWithResponse(CommunicationUserIdentifier c
public Mono<Void> revokeTokens(CommunicationUserIdentifier communicationUser) {
try {
Objects.requireNonNull(communicationUser);
return client.revokeAccessTokensAsync(communicationUser.getId())
return client.revokeAccessTokensWithResponse(communicationUser.getId(), noContentRequestOptions())
.then()
.onErrorMap(CommunicationErrorResponseException.class, IdentityErrorConverter::translateException);
} catch (RuntimeException ex) {
return monoError(logger, ex);
Expand All @@ -242,7 +282,7 @@ public Mono<Void> revokeTokens(CommunicationUserIdentifier communicationUser) {
public Mono<Response<Void>> revokeTokensWithResponse(CommunicationUserIdentifier communicationUser) {
try {
Objects.requireNonNull(communicationUser);
return client.revokeAccessTokensWithResponseAsync(communicationUser.getId())
return client.revokeAccessTokensWithResponse(communicationUser.getId(), noContentRequestOptions())
.onErrorMap(CommunicationErrorResponseException.class, IdentityErrorConverter::translateException);
} catch (RuntimeException ex) {
return monoError(logger, ex);
Expand All @@ -269,7 +309,7 @@ public Mono<AccessToken> getToken(CommunicationUserIdentifier communicationUser,
CommunicationIdentityAccessTokenRequest tokenRequest = CommunicationIdentityClientUtils
.createCommunicationIdentityAccessTokenRequest(scopes, tokenExpiresIn, logger);

return client.issueAccessTokenAsync(communicationUser.getId(), tokenRequest)
return client.issueAccessToken(communicationUser.getId(), tokenRequest)
.onErrorMap(CommunicationErrorResponseException.class, IdentityErrorConverter::translateException)
.flatMap((CommunicationIdentityAccessToken rawToken) -> {
return Mono.just(new AccessToken(rawToken.getToken(), rawToken.getExpiresOn()));
Expand Down Expand Up @@ -313,7 +353,10 @@ public Mono<Response<AccessToken>> getTokenWithResponse(CommunicationUserIdentif
CommunicationIdentityAccessTokenRequest tokenRequest = CommunicationIdentityClientUtils
.createCommunicationIdentityAccessTokenRequest(scopes, tokenExpiresIn, logger);

return client.issueAccessTokenWithResponseAsync(communicationUser.getId(), tokenRequest)
return client
.issueAccessTokenWithResponse(communicationUser.getId(), BinaryData.fromObject(tokenRequest),
new RequestOptions())
.map(response -> mapResponse(response, CommunicationIdentityAccessToken.class))
.onErrorMap(CommunicationErrorResponseException.class, IdentityErrorConverter::translateException)
.flatMap((Response<CommunicationIdentityAccessToken> response) -> {
AccessToken token
Expand Down Expand Up @@ -363,7 +406,7 @@ public Mono<Response<AccessToken>> getTokenWithResponse(CommunicationUserIdentif
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<AccessToken> getTokenForTeamsUser(GetTokenForTeamsUserOptions options) {
try {
return client.exchangeTeamsUserAccessTokenAsync(options)
return teamsUserClient.exchangeTeamsUserAccessToken(options)
.onErrorMap(CommunicationErrorResponseException.class, IdentityErrorConverter::translateException)
.flatMap((CommunicationIdentityAccessToken rawToken) -> {
return Mono.just(new AccessToken(rawToken.getToken(), rawToken.getExpiresOn()));
Expand All @@ -382,7 +425,9 @@ public Mono<AccessToken> getTokenForTeamsUser(GetTokenForTeamsUserOptions option
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<AccessToken>> getTokenForTeamsUserWithResponse(GetTokenForTeamsUserOptions options) {
try {
return client.exchangeTeamsUserAccessTokenWithResponseAsync(options)
return teamsUserClient
.exchangeTeamsUserAccessTokenWithResponse(BinaryData.fromObject(options), new RequestOptions())
.map(response -> mapResponse(response, CommunicationIdentityAccessToken.class))
.onErrorMap(CommunicationErrorResponseException.class, IdentityErrorConverter::translateException)
.flatMap((Response<CommunicationIdentityAccessToken> response) -> {
AccessToken token
Expand Down
Loading
Loading