Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dpg, upgrade webpubsub to 2022-11 #32125

Merged
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
582a155
regen and update source code
haolingdong-msft Nov 14, 2022
fe08c54
update tests to cover new features
haolingdong-msft Nov 14, 2022
82ec95b
update session-records
haolingdong-msft Nov 14, 2022
2cdc5ae
Merge remote-tracking branch 'remote/main' into webpubsub-upgrade-202…
haolingdong-msft Nov 14, 2022
d6bb162
update test case
haolingdong-msft Nov 14, 2022
2c7a93f
Fix checkstyle error
haolingdong-msft Nov 14, 2022
ac09258
update serviceVersion
haolingdong-msft Nov 16, 2022
233810c
update according to comments
haolingdong-msft Nov 16, 2022
7665d36
Add CHANGELOG
haolingdong-msft Nov 16, 2022
eff6695
Merge branch 'main' into webpubsub-upgrade-2022-11
haolingdong-msft Dec 16, 2022
bbd43d8
update cliam
haolingdong-msft Dec 16, 2022
374ffff
update group claim
haolingdong-msft Dec 16, 2022
5fe90e7
add sample on filters
haolingdong-msft Dec 19, 2022
7c9e24c
fix the wrong version value for 2021-10-01
haolingdong-msft Dec 19, 2022
497c56d
update CHANGELOG
haolingdong-msft Dec 19, 2022
76b3857
update pom and version_client
haolingdong-msft Dec 19, 2022
e8baf1e
update pom.xml
haolingdong-msft Dec 20, 2022
81ffefe
Merge remote-tracking branch 'remote/main' into webpubsub-upgrade-202…
haolingdong-msft Dec 20, 2022
fb3689a
update CHANGELOG
haolingdong-msft Dec 20, 2022
33448fa
Fix spotbugs error
haolingdong-msft Dec 20, 2022
6f4c306
use codesnippet and update sample
haolingdong-msft Dec 20, 2022
a66b129
nit: remove @Generated
haolingdong-msft Dec 28, 2022
0b8cb73
update samples according to comments
haolingdong-msft Jan 3, 2023
dfdda8e
Remove hub param from removeConnectionFromAllGroupsWithResponse API
haolingdong-msft Jan 4, 2023
c60fc7a
update according to comments
haolingdong-msft Jan 5, 2023
40d174d
Fix existing bug on generate client token using Aad token
haolingdong-msft Jan 5, 2023
b88b079
Add test
haolingdong-msft Jan 5, 2023
9e50e14
Fix checkstyle error
haolingdong-msft Jan 5, 2023
4b49bd5
update CHANGELOG
haolingdong-msft Jan 5, 2023
508cfe2
Fix spotbugs error
haolingdong-msft Jan 5, 2023
a206209
update tests
haolingdong-msft Jan 5, 2023
11d5d4e
Update according to comments
haolingdong-msft Jan 5, 2023
01f6b3c
Use parameterized tests
haolingdong-msft Jan 6, 2023
8aa9442
Remove recording json for skipInPlayback test
haolingdong-msft Jan 6, 2023
b1647a7
remove unused imports
haolingdong-msft Jan 6, 2023
3d9be36
Update sdk/webpubsub/azure-messaging-webpubsub/CHANGELOG.md
haolingdong-msft Jan 6, 2023
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
8 changes: 3 additions & 5 deletions sdk/webpubsub/azure-messaging-webpubsub/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@

### Features Added

### Breaking Changes

### Bugs Fixed

### Other Changes
- Added method `removeConnectionFromAllGroupsWithResponse` in `WebPubSubServiceClient` and `WebPubSubServiceAsyncClient` to remove the connection from all the groups it is in.
haolingdong-msft marked this conversation as resolved.
Show resolved Hide resolved
- Added a `webpubsub.group` option in `GetClientAccessTokenOptions`, to enable connections join initial groups once it is connected.
- Added a `filter` parameter when sending messages to connections in a hub/group/user to filter out the connections recieving message, details about `filter` syntax please see [OData filter syntax for Azure Web PubSub](https://aka.ms/awps/filter-syntax).

## 1.1.8 (2022-11-09)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ static String getAuthenticationToken(final String audienceUrl,
if (!CoreUtils.isNullOrEmpty(userId)) {
claimsBuilder.subject(userId);
}
if (!CoreUtils.isNullOrEmpty(options.getGroups())) {
claimsBuilder.claim("webpubsub.group", options.getGroups());
}
}

claimsBuilder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@

package com.azure.messaging.webpubsub;

import com.azure.core.annotation.Generated;
import com.azure.core.annotation.ReturnType;
import com.azure.core.annotation.ServiceClient;
import com.azure.core.annotation.ServiceMethod;
import com.azure.core.credential.AzureKeyCredential;
import com.azure.core.exception.ClientAuthenticationException;
import com.azure.core.exception.HttpResponseException;
import com.azure.core.exception.ResourceModifiedException;
import com.azure.core.exception.ResourceNotFoundException;
import com.azure.core.http.rest.RequestOptions;
import com.azure.core.http.rest.Response;
import com.azure.core.util.BinaryData;
Expand Down Expand Up @@ -67,6 +71,9 @@ public Mono<WebPubSubClientAccessToken> getClientAccessToken(GetClientAccessToke
if (CoreUtils.isNullOrEmpty(options.getRoles())) {
requestOptions.addQueryParam("role", options.getRoles().stream().collect(Collectors.joining(",")));
}
if (CoreUtils.isNullOrEmpty(options.getGroups())) {
requestOptions.addQueryParam("group", options.getGroups().stream().collect(Collectors.joining(",")));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: what if group name contains ,, will it be escaped?

}
requestOptions.addQueryParam("api-version", version.getVersion());
return this.serviceClient.generateClientTokenWithResponseAsync(hub, requestOptions)
.map(Response::getValue)
Expand Down Expand Up @@ -95,7 +102,7 @@ public Mono<WebPubSubClientAccessToken> getClientAccessToken(GetClientAccessToke
* <tr><td>userId</td><td>String</td><td>No</td><td>User Id.</td></tr>
* <tr><td>role</td><td>String</td><td>No</td><td>Roles that the connection with the generated token will have.</td></tr>
* <tr><td>minutesToExpire</td><td>String</td><td>No</td><td>The expire time of the generated token.</td></tr>
* <tr><td>apiVersion</td><td>String</td><td>No</td><td>Api Version</td></tr>
* <tr><td>group</td><td>Iterable&lt;String&gt;</td><td>No</td><td>Groups that the connection will join when it connects. Call {@link RequestOptions#addQueryParam} to add string to array.</td></tr>
* </table>
*
* <p><strong>Response Body Schema</strong>
Expand Down Expand Up @@ -134,7 +141,7 @@ public Mono<Response<Void>> sendToAllWithResponse(
}
requestOptions.setHeader("Content-Type", contentType.toString());
requestOptions.setHeader("Content-Length", String.valueOf(contentLength));
return this.serviceClient.sendToAllWithResponseAsync(hub, message, requestOptions);
return this.serviceClient.sendToAllWithResponseAsync(hub, "", message, requestOptions);
}

/**
Expand All @@ -148,7 +155,7 @@ public Mono<Response<Void>> sendToAllWithResponse(
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<Void>> sendToAllWithResponse(BinaryData message, RequestOptions requestOptions) {
return this.serviceClient.sendToAllWithResponseAsync(hub, message, requestOptions);
return this.serviceClient.sendToAllWithResponseAsync(hub, "", message, requestOptions);
}

/**
Expand Down Expand Up @@ -222,7 +229,7 @@ public Mono<Response<Void>> sendToConnectionWithResponse(
requestOptions.setHeader("Content-Type", contentType.toString());
requestOptions.setHeader("Content-Length", String.valueOf(contentLength));
return this.serviceClient.sendToConnectionWithResponseAsync(
hub, connectionId, message, requestOptions);
hub, connectionId, "", message, requestOptions);
}

/**
Expand All @@ -238,7 +245,7 @@ public Mono<Response<Void>> sendToConnectionWithResponse(
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<Void>> sendToConnectionWithResponse(
String connectionId, BinaryData message, RequestOptions requestOptions) {
return this.serviceClient.sendToConnectionWithResponseAsync(hub, connectionId, message, requestOptions);
return this.serviceClient.sendToConnectionWithResponseAsync(hub, connectionId, "", message, requestOptions);
}

/**
Expand Down Expand Up @@ -297,7 +304,7 @@ public Mono<Response<Void>> sendToGroupWithResponse(
requestOptions.setHeader("Content-Type", contentType.toString());
requestOptions.setHeader("Content-Length", String.valueOf(contentLength));
return this.serviceClient.sendToGroupWithResponseAsync(
hub, group, message, requestOptions);
hub, group, "", message, requestOptions);
}

/**
Expand All @@ -313,7 +320,7 @@ public Mono<Response<Void>> sendToGroupWithResponse(
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<Void>> sendToGroupWithResponse(
String group, BinaryData message, RequestOptions requestOptions) {
return this.serviceClient.sendToGroupWithResponseAsync(hub, group, message, requestOptions);
return this.serviceClient.sendToGroupWithResponseAsync(hub, group, "", message, requestOptions);
}

/**
Expand Down Expand Up @@ -365,6 +372,27 @@ public Mono<Response<Void>> removeConnectionFromGroupWithResponse(
return this.serviceClient.removeConnectionFromGroupWithResponseAsync(hub, group, connectionId, requestOptions);
}

/**
* Remove a connection from all groups.
*
* @param hub Target hub name, which should start with alphabetic characters and only contain alpha-numeric
* characters or underscore.
* @param connectionId Target connection Id.
* @param requestOptions The options to configure the HTTP request before HTTP client sends it.
* @throws HttpResponseException thrown if the request is rejected by server.
* @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
* @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
* @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the {@link Response} on successful completion of {@link Mono}.
*/
@Generated
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<Void>> removeConnectionFromAllGroupsWithResponse(
String hub, String connectionId, RequestOptions requestOptions) {
return this.serviceClient.removeConnectionFromAllGroupsWithResponseAsync(hub, connectionId, requestOptions);
}

/**
* Check if there are any client connections connected for the given user.
* @param userId Target user Id.
Expand Down Expand Up @@ -404,7 +432,7 @@ public Mono<Response<Void>> sendToUserWithResponse(
requestOptions.setHeader("Content-Type", contentType.toString());
requestOptions.setHeader("Content-Length", String.valueOf(contentLength));
return this.serviceClient.sendToUserWithResponseAsync(
hub, userId, message, requestOptions);
hub, userId, "", message, requestOptions);
}

/**
Expand All @@ -420,7 +448,7 @@ public Mono<Response<Void>> sendToUserWithResponse(
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<Void>> sendToUserWithResponse(
String userId, BinaryData message, RequestOptions requestOptions) {
return this.serviceClient.sendToUserWithResponseAsync(hub, userId, message, requestOptions);
return this.serviceClient.sendToUserWithResponseAsync(hub, userId, "", message, requestOptions);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
import com.azure.core.annotation.ServiceClient;
import com.azure.core.annotation.ServiceMethod;
import com.azure.core.credential.AzureKeyCredential;
import com.azure.core.exception.ClientAuthenticationException;
import com.azure.core.exception.HttpResponseException;
import com.azure.core.exception.ResourceModifiedException;
import com.azure.core.exception.ResourceNotFoundException;
import com.azure.core.http.rest.RequestOptions;
import com.azure.core.http.rest.Response;
import com.azure.core.util.BinaryData;
Expand Down Expand Up @@ -62,6 +65,9 @@ public WebPubSubClientAccessToken getClientAccessToken(GetClientAccessTokenOptio
if (CoreUtils.isNullOrEmpty(options.getRoles())) {
requestOptions.addQueryParam("role", options.getRoles().stream().collect(Collectors.joining(",")));
}
if (CoreUtils.isNullOrEmpty(options.getGroups())) {
requestOptions.addQueryParam("group", options.getGroups().stream().collect(Collectors.joining(",")));
}
requestOptions.addQueryParam("api-version", version.getVersion());
weidongxu-microsoft marked this conversation as resolved.
Show resolved Hide resolved
return this.serviceClient.generateClientTokenWithResponseAsync(hub, requestOptions)
.map(Response::getValue)
Expand All @@ -85,9 +91,9 @@ public WebPubSubClientAccessToken getClientAccessToken(GetClientAccessTokenOptio
* <caption>Query Parameters</caption>
* <tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr>
* <tr><td>userId</td><td>String</td><td>No</td><td>User Id.</td></tr>
* <tr><td>role</td><td>String</td><td>No</td><td>Roles that the connection with the generated token will have.</td></tr>
* <tr><td>minutesToExpire</td><td>String</td><td>No</td><td>The expire time of the generated token.</td></tr>
* <tr><td>apiVersion</td><td>String</td><td>No</td><td>Api Version</td></tr>
* <tr><td>role</td><td>Iterable&lt;String&gt;</td><td>No</td><td>Roles that the connection with the generated token will have. Call {@link RequestOptions#addQueryParam} to add string to array.</td></tr>
* <tr><td>minutesToExpire</td><td>Integer</td><td>No</td><td>The expire time of the generated token.</td></tr>
* <tr><td>group</td><td>Iterable&lt;String&gt;</td><td>No</td><td>Groups that the connection will join when it connects. Call {@link RequestOptions#addQueryParam} to add string to array.</td></tr>
* </table>
*
* <p><strong>Response Body Schema</strong>
Expand Down Expand Up @@ -133,7 +139,7 @@ public Response<Void> sendToAllWithResponse(
requestOptions.setHeader("Content-Type", contentType.toString());
requestOptions.setHeader("Content-Length", String.valueOf(contentLength));
return this.serviceClient.sendToAllWithResponse(
hub, message, requestOptions);
hub, "", message, requestOptions);
}

/**
Expand Down Expand Up @@ -162,7 +168,7 @@ public void sendToAll(String message, WebPubSubContentType contentType) {
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<Void> sendToAllWithResponse(
BinaryData message, RequestOptions requestOptions) {
return this.serviceClient.sendToAllWithResponse(hub, message, requestOptions);
return this.serviceClient.sendToAllWithResponse(hub, "", message, requestOptions);
}

/**
Expand Down Expand Up @@ -220,7 +226,7 @@ public Response<Void> sendToConnectionWithResponse(
requestOptions.setHeader("Content-Type", contentType.toString());
requestOptions.setHeader("Content-Length", String.valueOf(contentLength));
return this.serviceClient.sendToConnectionWithResponse(
hub, connectionId, message, requestOptions);
hub, connectionId, "", message, requestOptions);
}

/**
Expand Down Expand Up @@ -252,7 +258,7 @@ public void sendToConnection(
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<Void> sendToConnectionWithResponse(
String connectionId, BinaryData message, RequestOptions requestOptions) {
return this.serviceClient.sendToConnectionWithResponse(hub, connectionId, message, requestOptions);
return this.serviceClient.sendToConnectionWithResponse(hub, connectionId, "", message, requestOptions);
}

/**
Expand Down Expand Up @@ -295,7 +301,7 @@ public Response<Void> sendToGroupWithResponse(
requestOptions.setHeader("Content-Type", contentType.toString());
requestOptions.setHeader("Content-Length", String.valueOf(contentLength));
return this.serviceClient.sendToGroupWithResponse(
hub, group, message, requestOptions);
hub, group, "", message, requestOptions);
}

/**
Expand Down Expand Up @@ -326,7 +332,7 @@ public void sendToGroup(String group, String message, WebPubSubContentType conte
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<Void> sendToGroupWithResponse(
String group, BinaryData message, RequestOptions requestOptions) {
return this.serviceClient.sendToGroupWithResponse(hub, group, message, requestOptions);
return this.serviceClient.sendToGroupWithResponse(hub, group, "", message, requestOptions);
}

/**
Expand Down Expand Up @@ -362,6 +368,26 @@ public Response<Void> removeConnectionFromGroupWithResponse(
hub, group, connectionId, requestOptions);
}

/**
* Remove a connection from all groups.
*
* @param hub Target hub name, which should start with alphabetic characters and only contain alpha-numeric
* characters or underscore.
* @param connectionId Target connection Id.
* @param requestOptions The options to configure the HTTP request before HTTP client sends it.
* @throws HttpResponseException thrown if the request is rejected by server.
* @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
* @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
* @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the {@link Response}.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<Void> removeConnectionFromAllGroupsWithResponse(
String hub, String connectionId, RequestOptions requestOptions) {
return this.serviceClient.removeConnectionFromAllGroupsWithResponse(hub, connectionId, requestOptions);
}

/**
* Check if there are any client connections connected for the given user.
* @param userId Target user Id.
Expand Down Expand Up @@ -402,7 +428,7 @@ public Response<Void> sendToUserWithResponse(
requestOptions.setHeader("Content-Type", contentType.toString());
requestOptions.setHeader("Content-Length", String.valueOf(contentLength));
return this.serviceClient.sendToUserWithResponse(
hub, userId, message, requestOptions);
hub, userId, "", message, requestOptions);
}

/**
Expand Down Expand Up @@ -433,7 +459,7 @@ public void sendToUser(String userId, String message, WebPubSubContentType conte
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<Void> sendToUserWithResponse(
String userId, BinaryData message, RequestOptions requestOptions) {
return this.serviceClient.sendToUserWithResponse(hub, userId, message, requestOptions);
return this.serviceClient.sendToUserWithResponse(hub, userId, "", message, requestOptions);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,19 @@

/** Service version of WebPubSubService. */
public enum WebPubSubServiceVersion implements ServiceVersion {
/** Enum value 2021-10-01. */
V2021_10_01("2021-10-01");
/** Enum value 2021_10_01. */
V2021_10_01("2021_10_01"),

/** Enum value 2022-11-01. */
V2022_11_01("2022-11-01");
haolingdong-msft marked this conversation as resolved.
Show resolved Hide resolved

private final String version;

WebPubSubServiceVersion(String version) {
this.version = version;
}

/** {@inheritDoc} */
@Override
public String getVersion() {
return this.version;
Expand All @@ -28,6 +32,6 @@ public String getVersion() {
* @return The latest {@link WebPubSubServiceVersion}.
*/
public static WebPubSubServiceVersion getLatest() {
return V2021_10_01;
return V2022_11_01;
}
}
Loading