Skip to content

Commit a6fd991

Browse files
authored
Add presence API to webpubsub service sdk (Azure#45834)
1 parent bfb4adf commit a6fd991

File tree

15 files changed

+824
-58
lines changed

15 files changed

+824
-58
lines changed

eng/versioning/external_dependencies.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ org.codehaus.groovy:groovy-jsr223;3.0.19
8686
org.codehaus.janino:janino;3.1.10
8787
org.codehaus.woodstox:stax2-api;4.2.2
8888
org.conscrypt:conscrypt-openjdk-uber;2.5.2
89-
org.glassfish.tyrus:tyrus-client;1.16
89+
org.glassfish.tyrus:tyrus-container-grizzly-client;1.21
9090
org.openjfx:javafx-graphics;17.0.6
9191
org.graalvm.buildtools:junit-platform-native;0.9.19
9292
org.graalvm.buildtools:native-maven-plugin;0.10.5

eng/versioning/version_client.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ com.azure:azure-messaging-eventhubs-track2-perf;1.0.0-beta.1;1.0.0-beta.1
154154
com.azure:azure-messaging-servicebus;7.17.11;7.18.0-beta.2
155155
com.azure:azure-messaging-servicebus-stress;1.0.0-beta.1;1.0.0-beta.1
156156
com.azure:azure-messaging-servicebus-track2-perf;1.0.0-beta.1;1.0.0-beta.1
157-
com.azure:azure-messaging-webpubsub;1.4.1;1.5.0-beta.1
157+
com.azure:azure-messaging-webpubsub;1.4.1;1.5.0
158158
com.azure:azure-messaging-webpubsub-client;1.1.1;1.2.0-beta.1
159159
com.azure:azure-mixedreality-authentication;1.2.32;1.3.0-beta.1
160160
com.azure:azure-mixedreality-remoterendering;1.1.37;1.2.0-beta.1

sdk/webpubsub/azure-messaging-webpubsub-client/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
<dependency>
8383
<groupId>com.azure</groupId>
8484
<artifactId>azure-messaging-webpubsub</artifactId>
85-
<version>1.5.0-beta.1</version> <!-- {x-version-update;com.azure:azure-messaging-webpubsub;current} -->
85+
<version>1.5.0</version> <!-- {x-version-update;com.azure:azure-messaging-webpubsub;current} -->
8686
<scope>test</scope>
8787
</dependency>
8888
<dependency>

sdk/webpubsub/azure-messaging-webpubsub/CHANGELOG.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# Release History
22

3-
## 1.5.0-beta.1 (Unreleased)
3+
## 1.5.0 (Unreleased)
44

55
### Features Added
6+
- Add "listConnectionsInGroup" API.
67

78
### Breaking Changes
89

@@ -262,7 +263,7 @@
262263
### Bugs Fixed
263264

264265
- Fixed incorrect "audience" from `getClientAccessToken` method in `WebPubSubServiceAsyncClient`. ([#24741](https://github.com/Azure/azure-sdk-for-java/issues/24741))
265-
- Fixed bug of getting incorrect token in `getClientAccessToken` method from Azure token credential.
266+
- Fixed bug of getting incorrect token in `getClientAccessToken` method from Azure token credential.
266267

267268
### Features Added
268269

@@ -430,7 +431,7 @@
430431

431432
### Features Added
432433
- Added support for [Azure Active Directory](https://docs.microsoft.com/azure/active-directory/authentication/) based authentication.
433-
- Added support for API management by configuring `reverseProxyEndpoint` on the client builder.
434+
- Added support for API management by configuring `reverseProxyEndpoint` on the client builder.
434435
https://github.com/Azure/azure-webpubsub/issues/194 describes how to integrate with the API Management service.
435436

436437
## 1.0.0-beta.3 (2021-07-29)
@@ -449,9 +450,9 @@
449450
- Fixed issue with generating token that included only the last role in the input list.
450451

451452
## 1.0.0-beta.1 (2021-04-22)
452-
Version 1.0.0-beta.1 is a preview of our efforts in creating a client library for Azure Web PubSub that is
453-
developer-friendly, idiomatic to the Java ecosystem, and as consistent across different languages and platforms as
454-
possible. The principles that guide our efforts can be found in the
453+
Version 1.0.0-beta.1 is a preview of our efforts in creating a client library for Azure Web PubSub that is
454+
developer-friendly, idiomatic to the Java ecosystem, and as consistent across different languages and platforms as
455+
possible. The principles that guide our efforts can be found in the
455456
[Azure SDK Design Guidelines for Java](https://azure.github.io/azure-sdk/java_introduction.html).
456457

457458
- Initial release. Please see the README and wiki for information on using the new library.

sdk/webpubsub/azure-messaging-webpubsub/assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"AssetsRepo": "Azure/azure-sdk-assets",
33
"AssetsRepoPrefixPath": "java",
44
"TagPrefix": "java/webpubsub/azure-messaging-webpubsub",
5-
"Tag": "java/webpubsub/azure-messaging-webpubsub_b39e249795"
5+
"Tag": "java/webpubsub/azure-messaging-webpubsub_eeba9be155"
66
}

sdk/webpubsub/azure-messaging-webpubsub/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
<groupId>com.azure</groupId>
1515
<artifactId>azure-messaging-webpubsub</artifactId>
16-
<version>1.5.0-beta.1</version> <!-- {x-version-update;com.azure:azure-messaging-webpubsub;current} -->
16+
<version>1.5.0</version> <!-- {x-version-update;com.azure:azure-messaging-webpubsub;current} -->
1717

1818
<name>Microsoft Azure client library for Azure Web Pub Sub Service</name>
1919
<description>This package contains the Microsoft Azure Web Pub Sub library.</description>
@@ -81,8 +81,8 @@
8181
</dependency>
8282
<dependency>
8383
<groupId>org.glassfish.tyrus</groupId>
84-
<artifactId>tyrus-client</artifactId>
85-
<version>1.16</version> <!-- {x-version-update;org.glassfish.tyrus:tyrus-client;external_dependency} -->
84+
<artifactId>tyrus-container-grizzly-client</artifactId>
85+
<version>1.21</version> <!-- {x-version-update;org.glassfish.tyrus:tyrus-container-grizzly-client;external_dependency} -->
8686
<scope>test</scope>
8787
<exclusions>
8888
<exclusion>

sdk/webpubsub/azure-messaging-webpubsub/src/main/java/com/azure/messaging/webpubsub/WebPubSubServiceAsyncClient.java

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
import com.azure.core.exception.ResourceModifiedException;
1414
import com.azure.core.exception.ResourceNotFoundException;
1515
import com.azure.core.http.HttpHeaderName;
16+
import com.azure.core.http.rest.PagedFlux;
17+
import com.azure.core.http.rest.PagedResponse;
18+
import com.azure.core.http.rest.PagedResponseBase;
1619
import com.azure.core.http.rest.RequestOptions;
1720
import com.azure.core.http.rest.Response;
1821
import com.azure.core.util.BinaryData;
@@ -25,7 +28,10 @@
2528
import com.azure.messaging.webpubsub.models.GetClientAccessTokenOptions;
2629
import com.azure.messaging.webpubsub.models.WebPubSubClientAccessToken;
2730
import com.azure.messaging.webpubsub.models.WebPubSubContentType;
31+
import com.azure.messaging.webpubsub.models.WebPubSubGroupMember;
2832
import com.azure.messaging.webpubsub.models.WebPubSubPermission;
33+
34+
import reactor.core.publisher.Flux;
2935
import reactor.core.publisher.Mono;
3036

3137
import java.util.List;
@@ -409,6 +415,61 @@ public Mono<Void> addConnectionsToGroups(List<String> groups, String filter) {
409415
return addConnectionsToGroupsWithResponse(body, new RequestOptions()).flatMap(FluxUtil::toMono);
410416
}
411417

418+
/**
419+
* List connections in a group.
420+
* <p>
421+
* <strong>Query Parameters</strong>
422+
* </p>
423+
* <table border="1">
424+
* <caption>Query Parameters</caption>
425+
* <tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr>
426+
* <tr><td>maxpagesize</td><td>Integer</td><td>No</td><td>The maximum number of connections to include in a single response. It should be between 1 and 200.</td></tr>
427+
* <tr><td>top</td><td>Integer</td>
428+
* <td>No</td><td>The maximum number of connections to return. If the value is not set, then all the connections in a group are returned.</td></tr>
429+
* </table>
430+
* You can add these to a request with {@link RequestOptions#addQueryParam}
431+
* <p>
432+
* <strong>Response Body Schema</strong>
433+
* </p>
434+
*
435+
* <pre>
436+
* {@code
437+
* {
438+
* connectionId: String (Required)
439+
* userId: String (Optional)
440+
* }
441+
* }
442+
* </pre>
443+
*
444+
* @param hub Target hub name, which should start with alphabetic characters and only contain alpha-numeric characters or underscore.
445+
* @param group Target group name, whose length should be greater than 0 and less than 1025.
446+
* @param requestOptions The options to configure the HTTP request before HTTP client sends it.
447+
* @throws HttpResponseException thrown if the request is rejected by server.
448+
* @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
449+
* @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
450+
* @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
451+
* @return represents a page of elements as a LIST REST API result as paginated response with {@link PagedFlux}.
452+
*/
453+
@ServiceMethod(returns = ReturnType.COLLECTION)
454+
public PagedFlux<WebPubSubGroupMember> listConnectionsInGroup(String hub, String group,
455+
RequestOptions requestOptions) {
456+
PagedFlux<BinaryData> binaryDataPagedFlux
457+
= this.serviceClient.listConnectionsInGroupAsync(hub, group, requestOptions);
458+
459+
return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> {
460+
Flux<PagedResponse<BinaryData>> flux = (continuationTokenParam == null)
461+
? binaryDataPagedFlux.byPage().take(1)
462+
: binaryDataPagedFlux.byPage(continuationTokenParam).take(1);
463+
return flux.map(pagedResponse -> new PagedResponseBase<>(pagedResponse.getRequest(),
464+
pagedResponse.getStatusCode(), pagedResponse.getHeaders(),
465+
pagedResponse.getValue()
466+
.stream()
467+
.map(bd -> bd.toObject(WebPubSubGroupMember.class))
468+
.collect(java.util.stream.Collectors.toList()),
469+
pagedResponse.getContinuationToken(), null));
470+
});
471+
}
472+
412473
/**
413474
* Remove a connection from the target group.
414475
*

sdk/webpubsub/azure-messaging-webpubsub/src/main/java/com/azure/messaging/webpubsub/WebPubSubServiceClient.java

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import com.azure.core.exception.ResourceModifiedException;
1414
import com.azure.core.exception.ResourceNotFoundException;
1515
import com.azure.core.http.HttpHeaderName;
16+
import com.azure.core.http.rest.PagedIterable;
1617
import com.azure.core.http.rest.RequestOptions;
1718
import com.azure.core.http.rest.Response;
1819
import com.azure.core.util.BinaryData;
@@ -23,6 +24,7 @@
2324
import com.azure.messaging.webpubsub.models.GetClientAccessTokenOptions;
2425
import com.azure.messaging.webpubsub.models.WebPubSubClientAccessToken;
2526
import com.azure.messaging.webpubsub.models.WebPubSubContentType;
27+
import com.azure.messaging.webpubsub.models.WebPubSubGroupMember;
2628
import com.azure.messaging.webpubsub.models.WebPubSubPermission;
2729

2830
import java.util.List;
@@ -653,4 +655,43 @@ public Response<Void> closeGroupConnectionsWithResponse(String group, RequestOpt
653655
public Response<Void> closeUserConnectionsWithResponse(String userId, RequestOptions requestOptions) {
654656
return this.serviceClient.closeUserConnectionsWithResponse(hub, userId, requestOptions);
655657
}
658+
659+
/**
660+
* List connections in a group.
661+
* <p>
662+
* <strong>Query Parameters</strong>
663+
* </p>
664+
* <table border="1">
665+
* <caption>Query Parameters</caption>
666+
* <tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr>
667+
* <tr><td>maxpagesize</td><td>Integer</td><td>No</td><td>The maximum number of connections to include in a single response. It should be between 1 and 200.</td></tr>
668+
* <tr><td>top</td><td>Integer</td><td>No</td><td>The maximum number of connections to return. If the value is not set, then all the connections in a group are returned.</td></tr>
669+
* </table>
670+
* You can add these to a request with {@link RequestOptions#addQueryParam}
671+
* <p>
672+
* <strong>Response Body Schema</strong>
673+
* </p>
674+
*
675+
* <pre>
676+
* {@code
677+
* {
678+
* connectionId: String (Required)
679+
* userId: String (Optional)
680+
* }
681+
* }
682+
* </pre>
683+
*
684+
* @param group Target group name, whose length should be greater than 0 and less than 1025.
685+
* @param requestOptions The options to configure the HTTP request before HTTP client sends it.
686+
* @throws HttpResponseException thrown if the request is rejected by server.
687+
* @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
688+
* @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
689+
* @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
690+
* @return represents a page of elements as a LIST REST API result as paginated response with {@link PagedIterable}.
691+
*/
692+
@ServiceMethod(returns = ReturnType.COLLECTION)
693+
public PagedIterable<WebPubSubGroupMember> listConnectionsInGroup(String group, RequestOptions requestOptions) {
694+
return this.serviceClient.listConnectionsInGroup(hub, group, requestOptions)
695+
.mapPage(binaryData -> binaryData.toObject(WebPubSubGroupMember.class));
696+
}
656697
}

sdk/webpubsub/azure-messaging-webpubsub/src/main/java/com/azure/messaging/webpubsub/WebPubSubServiceVersion.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,12 @@ public enum WebPubSubServiceVersion implements ServiceVersion {
2323
/**
2424
* Enum value 2024-01-01.
2525
*/
26-
V2024_01_01("2024-01-01");
26+
V2024_01_01("2024-01-01"),
27+
28+
/**
29+
* Enum value 2024-12-01.
30+
*/
31+
V2024_12_01("2024-12-01");
2732

2833
private final String version;
2934

@@ -45,6 +50,6 @@ public String getVersion() {
4550
* @return The latest {@link WebPubSubServiceVersion}.
4651
*/
4752
public static WebPubSubServiceVersion getLatest() {
48-
return V2024_01_01;
53+
return V2024_12_01;
4954
}
5055
}

0 commit comments

Comments
 (0)