From ef74ffa2d274c8a3dc8e30162441e887335931af Mon Sep 17 00:00:00 2001 From: Zitong Yang Date: Wed, 14 Oct 2026 04:11:41 -0700 Subject: [PATCH 01/18] Add August 2026 preview support for Web PubSub Chat Generate from the corrected specification and update samples and documentation. Verify the complete sync/async live suite in Central US EUAP, remove the routing workaround, and upload sanitized latest-version recordings. Track the independent upstream async paging limitation without customization. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../azure-messaging-webpubsub-chat/AGENTS.md | 15 + .../CHANGELOG.md | 8 + .../KNOWN_ISSUES.md | 78 + .../azure-messaging-webpubsub-chat/README.md | 177 +- .../assets.json | 2 +- .../chat/WebPubSubChatServiceAsyncClient.java | 818 +++++++ .../chat/WebPubSubChatServiceClient.java | 721 ++++++ .../chat/WebPubSubChatServiceVersion.java | 9 +- .../implementation/JsonMergePatchHelper.java | 17 + .../WebPubSubChatServiceClientImpl.java | 1957 ++++++++++++++++- .../webpubsub/chat/models/ChatTopic.java | 276 +++ .../webpubsub/chat/models/ChatTopicState.java | 63 + .../webpubsub/chat/models/ChatUserRoom.java | 147 ++ ...ure-messaging-webpubsub-chat_metadata.json | 2 +- .../webpubsub/chat/WebPubSubChatSamples.java | 154 +- ...ChatServiceAugustAsyncClientLiveTests.java | 181 ++ .../ChatServiceAugustClientLiveTests.java | 156 ++ .../chat/ChatServiceClientTestBase.java | 14 +- .../chat/WebPubSubChatPaginationTests.java | 163 ++ ...ebPubSubChatServiceClientBuilderTests.java | 22 +- .../test-resources.bicep | 8 +- .../tsp-location.yaml | 2 +- sdk/webpubsub/tests.yml | 6 + 23 files changed, 4842 insertions(+), 154 deletions(-) create mode 100644 sdk/webpubsub/azure-messaging-webpubsub-chat/AGENTS.md create mode 100644 sdk/webpubsub/azure-messaging-webpubsub-chat/KNOWN_ISSUES.md create mode 100644 sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/ChatTopic.java create mode 100644 sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/ChatTopicState.java create mode 100644 sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/ChatUserRoom.java create mode 100644 sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/ChatServiceAugustAsyncClientLiveTests.java create mode 100644 sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/ChatServiceAugustClientLiveTests.java create mode 100644 sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/WebPubSubChatPaginationTests.java diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/AGENTS.md b/sdk/webpubsub/azure-messaging-webpubsub-chat/AGENTS.md new file mode 100644 index 0000000000000..da4bc5d0c5f6f --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/AGENTS.md @@ -0,0 +1,15 @@ +# Web PubSub Chat development constraints + +Before changing tests, recording tests, regenerating, or releasing this package, +read [KNOWN_ISSUES.md](KNOWN_ISSUES.md) for the pending upstream Java +generator paging fix. Do not add a paging customization; preserve strict +regression assertions and verify the upstream fix after regeneration. + +Run live tests against a Chat-enabled resource in the TTL = 7 days subscription. +The server routing fix was verified in Central US EUAP on 2026-10-13 using the +complete sync/async live suite. All operations, including setup and cleanup, +use `2026-08-01-preview`; do not restore legacy-version clients or routing skips. +Upload sanitized recordings and verify clean-cache playback after test changes. + +Before publishing an issue, PR, or team message for this package, show the user +the destination and exact draft and obtain explicit approval. diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/CHANGELOG.md b/sdk/webpubsub/azure-messaging-webpubsub-chat/CHANGELOG.md index 00a35e8be44c9..f45fc165207ec 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/CHANGELOG.md +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/CHANGELOG.md @@ -4,12 +4,20 @@ ### Features Added +- Added support for service API version `2026-08-01-preview`, now the default service version. +- Added synchronous and asynchronous operations to list rooms, users, and rooms associated with a user. +- Added topic creation, replacement, retrieval, update, soft deletion, and listing. +- Added `ChatTopic`, `ChatTopicState`, and the read-only `ChatUserRoom` projection. + ### Breaking Changes ### Bugs Fixed ### Other Changes +- Verified all existing and new operations end to end with `2026-08-01-preview` in Central US EUAP; removed the temporary server routing workaround and restored the complete live/playback suite. +- Tracked the upstream typed asynchronous page-size defect in [microsoft/typespec#12149](https://github.com/microsoft/typespec/issues/12149). No paging customization is applied; tests temporarily use protocol overloads for asynchronous page-size checks. + ## 1.0.0-beta.1 (2026-09-15) - Azure WebPubSubChat client library for Java. This package contains Microsoft Azure WebPubSubChat client library. diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/KNOWN_ISSUES.md b/sdk/webpubsub/azure-messaging-webpubsub-chat/KNOWN_ISSUES.md new file mode 100644 index 0000000000000..1542134077217 --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/KNOWN_ISSUES.md @@ -0,0 +1,78 @@ +# Web PubSub Chat SDK known generator issues + +## Typed asynchronous paging ignores the requested page size + +- **Tracking issue:** [microsoft/typespec#12149](https://github.com/microsoft/typespec/issues/12149). +- **Status:** Awaiting an upstream Java generator fix; reproduced with + `@azure-tools/typespec-java` 0.48.0 on 2026-10-09. +- **User decision:** Do not add a paging customization or manually repair + generated SDK code. Wait for the generator team to fix the implementation. + +The typed asynchronous paged convenience methods accept `pageSizeParam` but +discard it when delegating to `PagedFlux`. For example, +`asyncClient.listRoomsForUser("alice").byPage(1)` does not send `maxpagesize=1`. +Default continuation-token paging still works; the page-size override is +ignored. Synchronous typed paging forwards the page size correctly. + +This affects both existing operations (`listRoles`, `listRoomMembers`, +`listMessages`) and the new operations (`listRooms`, `listTopics`, `listUsers`, +`listRoomsForUser`). The defect predates this package's August API upgrade; the +first affected generator release has not been determined. + +### Approved temporary test workaround + +The user approved disabling only +`WebPubSubChatPaginationTests.asyncPageSizeReachesFirstAndNextRequests`; its +seven strict cases and assertions remain intact. New async live pagination tests +use the existing protocol overloads, such as +`asyncClient.listTopics(roomId, new RequestOptions()).byPage(1)`, and still assert +one item per page and follow continuation requests. Default typed async +collection/model coverage remains enabled. No production paging customization +or generated-code repair is applied. + +The mock suite also verifies first and next request page sizes for all seven +protocol async list methods. Passing these tests does not mean the typed async +generator defect is fixed. + +The implementation belongs to the shared +[Java generator in microsoft/typespec](https://github.com/microsoft/typespec/blob/main/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/ConvenienceAsyncMethodTemplate.java). +The original [Azure/typespec-azure#5657](https://github.com/Azure/typespec-azure/issues/5657) +was filed in the wrong repository and is closed. + +### Checking whether it has been fixed + +1. Check the tracking issue and the version of `@azure-tools/typespec-java` in + `eng/emitter-package.json`. An issue being closed does not prove that the + installed emitter includes the fix. +2. After the repository adopts a generator release containing the fix, + regenerate the package using its pinned `tsp-location.yaml`. Do not bypass + the issue by adding a customization. +3. Remove the issue-linked `@Disabled` annotation from + `asyncPageSizeReachesFirstAndNextRequests`, then run the strict, + credential-free regression tests: + + ```powershell + mvn -f sdk\webpubsub\azure-messaging-webpubsub-chat\pom.xml test "-Dtest=WebPubSubChatPaginationTests" "-Dgpg.skip=true" "-Drevapi.skip=true" + ``` + + `WebPubSubChatPaginationTests` covers all seven sync and async list operations. + It asserts `maxpagesize=1` on **both first-page and continuation requests**, + and checks that the corrected `listRoomsForUser` continuation overload sends + a query parameter. The original 16-case reproduction produced seven async + failures and nine passes. The protocol async cases were added for the + approved test workaround. Do not weaken the assertions or accept skipped async + page-size cases as evidence of a fix. +4. Verify the new sync/async live pagination scenarios, then verify sanitized + recording playback using the persisted `assets.json` tag. Check actual page + sizes and continuation requests, not only whether a non-empty page exists. +5. Only mark this issue resolved after the generated code and all strict + regression cases pass. Switch async live page-size checks back to the typed + overloads and remove the temporary test workaround at that point. + +### Server routing fix is independent + +The server routing issue was verified fixed in Central US EUAP on 2026-10-13: +all 14 sync/async live scenarios passed with `2026-08-01-preview`, including +existing operations and setup/cleanup. The routing workaround and its temporary +skill have been removed. This does not fix the typed async paging generator +defect; retain its strict regression cases and the protocol paging workaround. diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/README.md b/sdk/webpubsub/azure-messaging-webpubsub-chat/README.md index 3ffe57c22a48a..5201a93d40e15 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/README.md +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/README.md @@ -6,6 +6,8 @@ Use this client library in an application server to: - Create and manage Chat roles and permissions. - Create users, rooms, and room memberships. +- List rooms and users in a hub, or list the rooms associated with a user. +- Create, get, update, list, and soft delete topics in a room. - Get room conversations and query persisted message history. - Update and delete persisted messages. - Generate client access credentials for Chat WebSocket clients. @@ -21,19 +23,22 @@ Use this client library in an application server to: - An [Azure Web PubSub resource][create_instance]. - A Web PubSub hub with [Chat enabled][enable_chat]. -### 1. Add the package to your project +### Install the package + +The following dependency shows the current development version. It has not been +released to Maven Central; build it locally when evaluating the new API. [//]: # ({x-version-update-start;com.azure:azure-messaging-webpubsub-chat;current}) ```xml com.azure azure-messaging-webpubsub-chat - 1.0.0-beta.1 + 1.0.0-beta.2 ``` [//]: # ({x-version-update-end}) -### 2. Create and authenticate a `WebPubSubChatServiceClient` +### Create and authenticate a client The client supports a connection string, an `AzureKeyCredential`, or a Microsoft Entra ID token credential. The hub passed to the client must have Chat enabled. @@ -98,6 +103,19 @@ A user represents an application identity that can send and receive messages. A A room groups users together and is the primary organizational unit for chat interactions. Every room has an automatically created default conversation. +### Topic + +A topic is a named conversation in a room. Each topic has a title, creation time, +creator, conversation ID, ETag, and lifecycle state. `ChatTopicState` includes +`NORMAL`, `ARCHIVED`, and `SOFT_DELETED`. The August API adds topic management; +topic deletion is a soft delete rather than a room deletion. + +### User's rooms + +`listRoomsForUser` returns read-only `ChatUserRoom` projections of the rooms +associated with a user. A projection contains the room ID, title, default +conversation ID, and ETag; it does not provide a separate room lifecycle. + ### Room member A room member represents a user added to a room. Membership controls which users can receive and send messages in the room. Each room member is assigned a room role. @@ -131,47 +149,132 @@ String memberRole = BuiltInChatRoles.ROOM_MEMBER; ChatPermission publishPermission = ChatPermission.ROOM_PUBLISH_MESSAGE; ``` -### Create and list a custom role +The following examples are independent operations. Where an operation refers to +`general`, `alice`, or `announcements`, the corresponding resources must already +exist. All examples use the default `2026-08-01-preview` API version. + +### Create a custom role -```java readme-sample-manageChatRoles +```java readme-sample-createChatRole ChatRole moderator = new ChatRole(Arrays.asList(ChatPermission.ROOM_HISTORY, ChatPermission.ROOM_REMOVE_USER, ChatPermission.ROOM_PUBLISH_MESSAGE)); client.createOrReplaceRole("room.moderator", moderator); +``` +### List roles + +```java readme-sample-listChatRoles client.listRoles().forEach(role -> System.out.println(role.getName())); +``` + +### Delete a custom role + +```java readme-sample-deleteChatRole client.deleteRole("room.moderator"); ``` -### Create a user, room, and room membership +Remove references to a custom role before deleting it. + +### Create a user + +```java readme-sample-createChatUser +client.createOrReplaceUser("alice", new HumanChatUser("Alice", BuiltInChatRoles.USER_NORMAL)); +``` -```java readme-sample-manageChatRooms -client.createOrReplaceRole("user.room_creator", - new ChatRole(Arrays.asList(ChatPermission.USER_CREATE_ROOM))); -client.createOrReplaceRole("room.contributor", - new ChatRole(Arrays.asList(ChatPermission.ROOM_PUBLISH_MESSAGE))); -client.createOrReplaceUser("alice", new HumanChatUser("Alice", "user.room_creator")); +### Create a room +```java readme-sample-createChatRoom ChatRoom room = client.createOrReplaceRoom("general", new ChatRoom("General")); +String defaultConversationId = room.getDefaultConversation(); +``` + +### Add a room member + +```java readme-sample-addChatRoomMember ChatRoomMember member = client.createOrReplaceRoomMember( - room.getId(), "alice", new ChatRoomMember("room.contributor")); + "general", "alice", new ChatRoomMember(BuiltInChatRoles.ROOM_MEMBER)); System.out.printf("%s: %s%n", member.getUserId(), member.getRoleName()); +``` + +### List rooms -client.deleteRoom(room.getId()); -client.deleteUser("alice"); -client.deleteRole("room.contributor"); -client.deleteRole("user.room_creator"); +```java readme-sample-listChatRooms +client.listRooms().forEach(room -> System.out.printf("%s: %s%n", room.getId(), room.getTitle())); ``` -Delete dependent resources in reverse order when they are no longer needed: room, user, and then roles. +### List users + +```java readme-sample-listChatUsers +client.listUsers().forEach(user -> System.out.printf("%s: %s%n", user.getId(), user.getNickname())); +``` + +### List rooms for a user + +```java readme-sample-listChatRoomsForUser +client.listRoomsForUser("alice").forEach(room -> + System.out.printf("%s: %s%n", room.getId(), room.getTitle())); +``` + +List operations return `PagedIterable` on the synchronous client and `PagedFlux` +on the asynchronous client. Iteration fetches subsequent pages automatically. +To process synchronous results page by page, use `iterableByPage(pageSize)`. + +### Create a topic + +The parent room must already exist. + +```java readme-sample-createChatTopic +ChatTopic topic = client.createOrReplaceTopic("general", "announcements", + new ChatTopic().setTitle("Announcements")); +String conversationId = topic.getConversationId(); +``` + +Use the returned conversation ID when a Chat WebSocket client sends messages to +the topic. This server-side library manages resources and persisted messages; +it is not a WebSocket chat client. + +### Get a topic + +```java readme-sample-getChatTopic +ChatTopic topic = client.getTopic("general", "announcements"); +System.out.printf("%s: %s%n", topic.getTitle(), topic.getState()); +``` + +### Update a topic + +Only explicitly set properties are included in the merge-patch request. +Use the overload accepting `MatchConditions` and the current ETag to prevent +overwriting another caller's changes. + +```java readme-sample-updateChatTopic +ChatTopic updated = client.updateTopic("general", "announcements", + new ChatTopic().setTitle("Archived announcements").setState(ChatTopicState.ARCHIVED)); +``` + +### List topics + +```java readme-sample-listChatTopics +client.listTopics("general").forEach(topic -> + System.out.printf("%s: %s%n", topic.getId(), topic.getTitle())); +``` + +### Soft delete a topic + +```java readme-sample-deleteChatTopic +client.deleteTopic("general", "announcements"); +``` ### List persisted messages ```java readme-sample-listChatMessages -ChatRoom room = client.getRoom("general"); -client.listMessages(room.getDefaultConversation()).forEach(message -> +String conversationId = ""; +client.listMessages(conversationId).forEach(message -> System.out.printf("%s: %s%n", message.getCreatedBy(), message.getContent().getText())); ``` +Use a conversation ID returned by room or topic creation. Message history +queries return messages from latest to earliest. + ### Use the asynchronous client ```java readme-sample-createAsyncChatClient @@ -179,13 +282,41 @@ WebPubSubChatServiceAsyncClient asyncClient = new WebPubSubChatServiceClientBuil .connectionString("") .hub("chat") .buildAsyncClient(); +``` -asyncClient.listRoles().subscribe(role -> System.out.println(role.getName())); +Subscribe to the returned publisher to execute an asynchronous operation, and +handle errors explicitly: + +```java readme-sample-listChatTopicsAsync +asyncClient.listTopics("general").subscribe( + topic -> System.out.println(topic.getTitle()), + error -> System.err.println("Could not list topics: " + error.getMessage())); +``` + +#### Known asynchronous page-size limitation + +The generator currently ignores `byPage(pageSize)` on typed asynchronous +collections. Default continuation paging is unaffected. Until +[microsoft/typespec#12149](https://github.com/microsoft/typespec/issues/12149) +is fixed in the emitter used by this package, use the existing protocol overload +when an explicit asynchronous page size is required: + +```java readme-sample-listChatTopicsAsyncByPage +asyncClient.listTopics("general", new RequestOptions()).byPage(10).subscribe( + page -> page.getValue().forEach(data -> System.out.println(data.toObject(ChatTopic.class).getTitle())), + error -> System.err.println("Could not list topic pages: " + error.getMessage())); ``` +See [known generator issues](KNOWN_ISSUES.md) for verification and removal of the +temporary test workaround. No paging customization is applied. + ### Service API versions -The client library targets the latest service API version by default. To use another supported version, pass a `WebPubSubChatServiceVersion` to the builder's `serviceVersion` method. Verify that the selected version supports the operations and models used by your application. +The default is `WebPubSubChatServiceVersion.V2026_08_01_PREVIEW`. The library also +supports `V2026_02_01_PREVIEW` for existing operations. Topic operations and the +new room/user listing operations require the August version. To select a version, +pass it to the builder's `serviceVersion` method. All operations are supported +with the August API; no separate client is needed for existing operations. ## Troubleshooting @@ -210,6 +341,8 @@ Explore the [complete package samples][samples] to learn how to: - Authenticate with a connection string, access key, or Microsoft Entra ID. - Manage roles, permissions, users, rooms, and room members. +- List rooms and users, and query rooms associated with a user. +- Manage topics and their lifecycle states. - Generate client access credentials. - Query, update, and delete message history. - Use synchronous and asynchronous clients. diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/assets.json b/sdk/webpubsub/azure-messaging-webpubsub-chat/assets.json index 946f2266fe205..6927e8604a559 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/assets.json +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/assets.json @@ -1 +1 @@ -{"AssetsRepo":"Azure/azure-sdk-assets","AssetsRepoPrefixPath":"java","TagPrefix":"java/webpubsub/azure-messaging-webpubsub-chat","Tag": "java/webpubsub/azure-messaging-webpubsub-chat_395861d3d4"} \ No newline at end of file +{"AssetsRepo":"Azure/azure-sdk-assets","AssetsRepoPrefixPath":"java","TagPrefix":"java/webpubsub/azure-messaging-webpubsub-chat","Tag": "java/webpubsub/azure-messaging-webpubsub-chat_a649b09111"} \ No newline at end of file diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceAsyncClient.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceAsyncClient.java index acd46bde95c3d..1b5dc45cd5de5 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceAsyncClient.java +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceAsyncClient.java @@ -28,7 +28,9 @@ import com.azure.messaging.webpubsub.chat.models.ChatRole; import com.azure.messaging.webpubsub.chat.models.ChatRoom; import com.azure.messaging.webpubsub.chat.models.ChatRoomMember; +import com.azure.messaging.webpubsub.chat.models.ChatTopic; import com.azure.messaging.webpubsub.chat.models.ChatUser; +import com.azure.messaging.webpubsub.chat.models.ChatUserRoom; import com.azure.messaging.webpubsub.chat.models.GetClientAccessTokenOptions; import com.azure.messaging.webpubsub.chat.models.WebPubSubClientAccessToken; import java.util.stream.Collectors; @@ -1660,4 +1662,820 @@ public Mono deleteUser(String userId) { public Mono getClientAccessToken(GetClientAccessTokenOptions options) { return WebPubSubClientAccessTokenFactory.createAsync(serviceClient, keyCredential, options); } + + /** + * List rooms with pagination. + *

Query Parameters

+ * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
maxpagesizeIntegerNoThe maximum number of result items per page.
continuationTokenStringNoContinuation token for pagination.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     title: String (Required)
+     *     defaultConversation: String (Required)
+     *     etag: String (Required)
+     * }
+     * }
+     * 
+ * + * @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. + * @return paged collection of ChatRoom items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listRooms(RequestOptions requestOptions) { + return this.serviceClient.listRoomsAsync(requestOptions); + } + + /** + * List topics in a room with pagination. + *

Query Parameters

+ * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
maxpagesizeIntegerNoThe maximum number of result items per page.
continuationTokenStringNoContinuation token for pagination.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     title: String (Optional, Required on create)
+     *     createdAt: OffsetDateTime (Required)
+     *     createdBy: String (Required)
+     *     state: String(Normal/Archived/SoftDeleted) (Optional, Required on create)
+     *     conversationId: String (Required)
+     *     etag: String (Required)
+     * }
+     * }
+     * 
+ * + * @param roomId Room identifier. + * @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. + * @return paged collection of ChatTopic items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listTopics(String roomId, RequestOptions requestOptions) { + return this.serviceClient.listTopicsAsync(roomId, requestOptions); + } + + /** + * Create or replace a topic. + * + * Create or replace a topic with a client-specified ID. + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     title: String (Optional, Required on create)
+     *     createdAt: OffsetDateTime (Required)
+     *     createdBy: String (Required)
+     *     state: String(Normal/Archived/SoftDeleted) (Optional, Required on create)
+     *     conversationId: String (Required)
+     *     etag: String (Required)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     title: String (Optional, Required on create)
+     *     createdAt: OffsetDateTime (Required)
+     *     createdBy: String (Required)
+     *     state: String(Normal/Archived/SoftDeleted) (Optional, Required on create)
+     *     conversationId: String (Required)
+     *     etag: String (Required)
+     * }
+     * }
+     * 
+ * + *

Response Headers

+ * + * + * + * + *
Response Headers
NameTypeDescription
ETagStringThe entity tag for the response.
+ * + * @param roomId Room identifier. + * @param topicId Topic identifier unique within the room. + * @param resource The resource instance. + * @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. + * @return represents a chat topic in a room along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> createOrReplaceTopicWithResponse(String roomId, String topicId, + BinaryData resource, RequestOptions requestOptions) { + return this.serviceClient.createOrReplaceTopicWithResponseAsync(roomId, topicId, resource, requestOptions); + } + + /** + * Get topic information. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     title: String (Optional, Required on create)
+     *     createdAt: OffsetDateTime (Required)
+     *     createdBy: String (Required)
+     *     state: String(Normal/Archived/SoftDeleted) (Optional, Required on create)
+     *     conversationId: String (Required)
+     *     etag: String (Required)
+     * }
+     * }
+     * 
+ * + * @param roomId Room identifier. + * @param topicId Topic identifier unique within the room. + * @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. + * @return topic information along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getTopicWithResponse(String roomId, String topicId, + RequestOptions requestOptions) { + return this.serviceClient.getTopicWithResponseAsync(roomId, topicId, requestOptions); + } + + /** + * Update a topic. + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     title: String (Optional, Required on create)
+     *     createdAt: OffsetDateTime (Required)
+     *     createdBy: String (Required)
+     *     state: String(Normal/Archived/SoftDeleted) (Optional, Required on create)
+     *     conversationId: String (Required)
+     *     etag: String (Required)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     title: String (Optional, Required on create)
+     *     createdAt: OffsetDateTime (Required)
+     *     createdBy: String (Required)
+     *     state: String(Normal/Archived/SoftDeleted) (Optional, Required on create)
+     *     conversationId: String (Required)
+     *     etag: String (Required)
+     * }
+     * }
+     * 
+ * + *

Response Headers

+ * + * + * + * + *
Response Headers
NameTypeDescription
ETagStringThe entity tag for the response.
+ * + * @param roomId Room identifier. + * @param topicId Topic identifier unique within the room. + * @param resource The resource instance. + * @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. + * @return represents a chat topic in a room along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> updateTopicWithResponse(String roomId, String topicId, BinaryData resource, + RequestOptions requestOptions) { + return this.serviceClient.updateTopicWithResponseAsync(roomId, topicId, resource, requestOptions); + } + + /** + * Soft delete a topic. + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param roomId Room identifier. + * @param topicId Topic identifier unique within the room. + * @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. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> deleteTopicWithResponse(String roomId, String topicId, RequestOptions requestOptions) { + return this.serviceClient.deleteTopicWithResponseAsync(roomId, topicId, requestOptions); + } + + /** + * List all users with pagination. + *

Query Parameters

+ * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
maxpagesizeIntegerNoThe maximum number of result items per page.
continuationTokenStringNoContinuation token for pagination.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String(Human) (Required)
+     *     id: String (Required)
+     *     nickname: String (Required)
+     *     etag: String (Required)
+     * }
+     * }
+     * 
+ * + * @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. + * @return paged collection of ChatUser items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listUsers(RequestOptions requestOptions) { + return this.serviceClient.listUsersAsync(requestOptions); + } + + /** + * List rooms for a user with pagination. + *

Query Parameters

+ * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
maxpagesizeIntegerNoThe maximum number of result items per page.
continuationTokenStringNoContinuation token for pagination.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     title: String (Required)
+     *     defaultConversation: String (Required)
+     *     etag: String (Required)
+     * }
+     * }
+     * 
+ * + * @param userId User identifier. + * @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. + * @return paged collection of ChatUserRoom items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listRoomsForUser(String userId, RequestOptions requestOptions) { + return this.serviceClient.listRoomsForUserAsync(userId, requestOptions); + } + + /** + * List rooms with pagination. + * + * @param continuationToken Continuation token for pagination. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @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 paged collection of ChatRoom items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listRooms(String continuationToken) { + // Generated convenience method for listRooms + RequestOptions requestOptions = new RequestOptions(); + if (continuationToken != null) { + requestOptions.addQueryParam("continuationToken", continuationToken, false); + } + PagedFlux pagedFluxResponse = listRooms(requestOptions); + return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { + Flux> flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationTokenParam).take(1); + return flux.map(pagedResponse -> new PagedResponseBase(pagedResponse.getRequest(), + pagedResponse.getStatusCode(), pagedResponse.getHeaders(), + pagedResponse.getValue() + .stream() + .map(protocolMethodData -> protocolMethodData.toObject(ChatRoom.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), null)); + }); + } + + /** + * List rooms with pagination. + * + * @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 paged collection of ChatRoom items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listRooms() { + // Generated convenience method for listRooms + RequestOptions requestOptions = new RequestOptions(); + PagedFlux pagedFluxResponse = listRooms(requestOptions); + return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { + Flux> flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationTokenParam).take(1); + return flux.map(pagedResponse -> new PagedResponseBase(pagedResponse.getRequest(), + pagedResponse.getStatusCode(), pagedResponse.getHeaders(), + pagedResponse.getValue() + .stream() + .map(protocolMethodData -> protocolMethodData.toObject(ChatRoom.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), null)); + }); + } + + /** + * List topics in a room with pagination. + * + * @param roomId Room identifier. + * @param continuationToken Continuation token for pagination. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @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 paged collection of ChatTopic items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listTopics(String roomId, String continuationToken) { + // Generated convenience method for listTopics + RequestOptions requestOptions = new RequestOptions(); + if (continuationToken != null) { + requestOptions.addQueryParam("continuationToken", continuationToken, false); + } + PagedFlux pagedFluxResponse = listTopics(roomId, requestOptions); + return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { + Flux> flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationTokenParam).take(1); + return flux.map(pagedResponse -> new PagedResponseBase(pagedResponse.getRequest(), + pagedResponse.getStatusCode(), pagedResponse.getHeaders(), + pagedResponse.getValue() + .stream() + .map(protocolMethodData -> protocolMethodData.toObject(ChatTopic.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), null)); + }); + } + + /** + * List topics in a room with pagination. + * + * @param roomId Room identifier. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @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 paged collection of ChatTopic items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listTopics(String roomId) { + // Generated convenience method for listTopics + RequestOptions requestOptions = new RequestOptions(); + PagedFlux pagedFluxResponse = listTopics(roomId, requestOptions); + return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { + Flux> flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationTokenParam).take(1); + return flux.map(pagedResponse -> new PagedResponseBase(pagedResponse.getRequest(), + pagedResponse.getStatusCode(), pagedResponse.getHeaders(), + pagedResponse.getValue() + .stream() + .map(protocolMethodData -> protocolMethodData.toObject(ChatTopic.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), null)); + }); + } + + /** + * Create or replace a topic. + * + * Create or replace a topic with a client-specified ID. + * + * @param roomId Room identifier. + * @param topicId Topic identifier unique within the room. + * @param resource The resource instance. + * @param matchConditions Specifies HTTP options for conditional requests. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @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 represents a chat topic in a room on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono createOrReplaceTopic(String roomId, String topicId, ChatTopic resource, + MatchConditions matchConditions) { + // Generated convenience method for createOrReplaceTopicWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = matchConditions == null ? null : matchConditions.getIfMatch(); + String ifNoneMatch = matchConditions == null ? null : matchConditions.getIfNoneMatch(); + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + return createOrReplaceTopicWithResponse(roomId, topicId, BinaryData.fromObject(resource), requestOptions) + .flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(ChatTopic.class)); + } + + /** + * Create or replace a topic. + * + * Create or replace a topic with a client-specified ID. + * + * @param roomId Room identifier. + * @param topicId Topic identifier unique within the room. + * @param resource The resource instance. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @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 represents a chat topic in a room on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono createOrReplaceTopic(String roomId, String topicId, ChatTopic resource) { + // Generated convenience method for createOrReplaceTopicWithResponse + RequestOptions requestOptions = new RequestOptions(); + return createOrReplaceTopicWithResponse(roomId, topicId, BinaryData.fromObject(resource), requestOptions) + .flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(ChatTopic.class)); + } + + /** + * Get topic information. + * + * @param roomId Room identifier. + * @param topicId Topic identifier unique within the room. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @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 topic information on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getTopic(String roomId, String topicId) { + // Generated convenience method for getTopicWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getTopicWithResponse(roomId, topicId, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(ChatTopic.class)); + } + + /** + * Update a topic. + * + * @param roomId Room identifier. + * @param topicId Topic identifier unique within the room. + * @param resource The resource instance. + * @param matchConditions Specifies HTTP options for conditional requests. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @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 represents a chat topic in a room on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono updateTopic(String roomId, String topicId, ChatTopic resource, + MatchConditions matchConditions) { + // Generated convenience method for updateTopicWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = matchConditions == null ? null : matchConditions.getIfMatch(); + String ifNoneMatch = matchConditions == null ? null : matchConditions.getIfNoneMatch(); + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + JsonMergePatchHelper.getChatTopicAccessor().prepareModelForJsonMergePatch(resource, true); + BinaryData resourceInBinaryData = BinaryData.fromObject(resource); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + resourceInBinaryData.getLength(); + JsonMergePatchHelper.getChatTopicAccessor().prepareModelForJsonMergePatch(resource, false); + return updateTopicWithResponse(roomId, topicId, resourceInBinaryData, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(ChatTopic.class)); + } + + /** + * Update a topic. + * + * @param roomId Room identifier. + * @param topicId Topic identifier unique within the room. + * @param resource The resource instance. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @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 represents a chat topic in a room on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono updateTopic(String roomId, String topicId, ChatTopic resource) { + // Generated convenience method for updateTopicWithResponse + RequestOptions requestOptions = new RequestOptions(); + JsonMergePatchHelper.getChatTopicAccessor().prepareModelForJsonMergePatch(resource, true); + BinaryData resourceInBinaryData = BinaryData.fromObject(resource); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + resourceInBinaryData.getLength(); + JsonMergePatchHelper.getChatTopicAccessor().prepareModelForJsonMergePatch(resource, false); + return updateTopicWithResponse(roomId, topicId, resourceInBinaryData, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(ChatTopic.class)); + } + + /** + * Soft delete a topic. + * + * @param roomId Room identifier. + * @param topicId Topic identifier unique within the room. + * @param matchConditions Specifies HTTP options for conditional requests. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @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 A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono deleteTopic(String roomId, String topicId, MatchConditions matchConditions) { + // Generated convenience method for deleteTopicWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = matchConditions == null ? null : matchConditions.getIfMatch(); + String ifNoneMatch = matchConditions == null ? null : matchConditions.getIfNoneMatch(); + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + return deleteTopicWithResponse(roomId, topicId, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Soft delete a topic. + * + * @param roomId Room identifier. + * @param topicId Topic identifier unique within the room. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @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 A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono deleteTopic(String roomId, String topicId) { + // Generated convenience method for deleteTopicWithResponse + RequestOptions requestOptions = new RequestOptions(); + return deleteTopicWithResponse(roomId, topicId, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * List all users with pagination. + * + * @param continuationToken Continuation token for pagination. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @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 paged collection of ChatUser items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listUsers(String continuationToken) { + // Generated convenience method for listUsers + RequestOptions requestOptions = new RequestOptions(); + if (continuationToken != null) { + requestOptions.addQueryParam("continuationToken", continuationToken, false); + } + PagedFlux pagedFluxResponse = listUsers(requestOptions); + return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { + Flux> flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationTokenParam).take(1); + return flux.map(pagedResponse -> new PagedResponseBase(pagedResponse.getRequest(), + pagedResponse.getStatusCode(), pagedResponse.getHeaders(), + pagedResponse.getValue() + .stream() + .map(protocolMethodData -> protocolMethodData.toObject(ChatUser.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), null)); + }); + } + + /** + * List all users with pagination. + * + * @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 paged collection of ChatUser items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listUsers() { + // Generated convenience method for listUsers + RequestOptions requestOptions = new RequestOptions(); + PagedFlux pagedFluxResponse = listUsers(requestOptions); + return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { + Flux> flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationTokenParam).take(1); + return flux.map(pagedResponse -> new PagedResponseBase(pagedResponse.getRequest(), + pagedResponse.getStatusCode(), pagedResponse.getHeaders(), + pagedResponse.getValue() + .stream() + .map(protocolMethodData -> protocolMethodData.toObject(ChatUser.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), null)); + }); + } + + /** + * List rooms for a user with pagination. + * + * @param userId User identifier. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @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 paged collection of ChatUserRoom items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listRoomsForUser(String userId) { + // Generated convenience method for listRoomsForUser + RequestOptions requestOptions = new RequestOptions(); + PagedFlux pagedFluxResponse = listRoomsForUser(userId, requestOptions); + return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { + Flux> flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationTokenParam).take(1); + return flux.map(pagedResponse -> new PagedResponseBase(pagedResponse.getRequest(), + pagedResponse.getStatusCode(), pagedResponse.getHeaders(), + pagedResponse.getValue() + .stream() + .map(protocolMethodData -> protocolMethodData.toObject(ChatUserRoom.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), null)); + }); + } + + /** + * List rooms for a user with pagination. + * + * @param userId User identifier. + * @param continuationToken Continuation token for pagination. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @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 paged collection of ChatUserRoom items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listRoomsForUser(String userId, String continuationToken) { + // Generated convenience method for listRoomsForUser + RequestOptions requestOptions = new RequestOptions(); + if (continuationToken != null) { + requestOptions.addQueryParam("continuationToken", continuationToken, false); + } + PagedFlux pagedFluxResponse = listRoomsForUser(userId, requestOptions); + return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { + Flux> flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationTokenParam).take(1); + return flux.map(pagedResponse -> new PagedResponseBase(pagedResponse.getRequest(), + pagedResponse.getStatusCode(), pagedResponse.getHeaders(), + pagedResponse.getValue() + .stream() + .map(protocolMethodData -> protocolMethodData.toObject(ChatUserRoom.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), null)); + }); + } } diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceClient.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceClient.java index 8de3fda06d8a1..2551384dd5872 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceClient.java +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceClient.java @@ -25,7 +25,9 @@ import com.azure.messaging.webpubsub.chat.models.ChatRole; import com.azure.messaging.webpubsub.chat.models.ChatRoom; import com.azure.messaging.webpubsub.chat.models.ChatRoomMember; +import com.azure.messaging.webpubsub.chat.models.ChatTopic; import com.azure.messaging.webpubsub.chat.models.ChatUser; +import com.azure.messaging.webpubsub.chat.models.ChatUserRoom; import com.azure.messaging.webpubsub.chat.models.GetClientAccessTokenOptions; import com.azure.messaging.webpubsub.chat.models.WebPubSubClientAccessToken; @@ -1516,4 +1518,723 @@ public void deleteUser(String userId) { public WebPubSubClientAccessToken getClientAccessToken(GetClientAccessTokenOptions options) { return WebPubSubClientAccessTokenFactory.create(serviceClient, keyCredential, options); } + + /** + * List rooms with pagination. + *

Query Parameters

+ * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
maxpagesizeIntegerNoThe maximum number of result items per page.
continuationTokenStringNoContinuation token for pagination.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     title: String (Required)
+     *     defaultConversation: String (Required)
+     *     etag: String (Required)
+     * }
+     * }
+     * 
+ * + * @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. + * @return paged collection of ChatRoom items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listRooms(RequestOptions requestOptions) { + return this.serviceClient.listRooms(requestOptions); + } + + /** + * List topics in a room with pagination. + *

Query Parameters

+ * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
maxpagesizeIntegerNoThe maximum number of result items per page.
continuationTokenStringNoContinuation token for pagination.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     title: String (Optional, Required on create)
+     *     createdAt: OffsetDateTime (Required)
+     *     createdBy: String (Required)
+     *     state: String(Normal/Archived/SoftDeleted) (Optional, Required on create)
+     *     conversationId: String (Required)
+     *     etag: String (Required)
+     * }
+     * }
+     * 
+ * + * @param roomId Room identifier. + * @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. + * @return paged collection of ChatTopic items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listTopics(String roomId, RequestOptions requestOptions) { + return this.serviceClient.listTopics(roomId, requestOptions); + } + + /** + * Create or replace a topic. + * + * Create or replace a topic with a client-specified ID. + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     title: String (Optional, Required on create)
+     *     createdAt: OffsetDateTime (Required)
+     *     createdBy: String (Required)
+     *     state: String(Normal/Archived/SoftDeleted) (Optional, Required on create)
+     *     conversationId: String (Required)
+     *     etag: String (Required)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     title: String (Optional, Required on create)
+     *     createdAt: OffsetDateTime (Required)
+     *     createdBy: String (Required)
+     *     state: String(Normal/Archived/SoftDeleted) (Optional, Required on create)
+     *     conversationId: String (Required)
+     *     etag: String (Required)
+     * }
+     * }
+     * 
+ * + *

Response Headers

+ * + * + * + * + *
Response Headers
NameTypeDescription
ETagStringThe entity tag for the response.
+ * + * @param roomId Room identifier. + * @param topicId Topic identifier unique within the room. + * @param resource The resource instance. + * @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. + * @return represents a chat topic in a room along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createOrReplaceTopicWithResponse(String roomId, String topicId, BinaryData resource, + RequestOptions requestOptions) { + return this.serviceClient.createOrReplaceTopicWithResponse(roomId, topicId, resource, requestOptions); + } + + /** + * Get topic information. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     title: String (Optional, Required on create)
+     *     createdAt: OffsetDateTime (Required)
+     *     createdBy: String (Required)
+     *     state: String(Normal/Archived/SoftDeleted) (Optional, Required on create)
+     *     conversationId: String (Required)
+     *     etag: String (Required)
+     * }
+     * }
+     * 
+ * + * @param roomId Room identifier. + * @param topicId Topic identifier unique within the room. + * @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. + * @return topic information along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getTopicWithResponse(String roomId, String topicId, RequestOptions requestOptions) { + return this.serviceClient.getTopicWithResponse(roomId, topicId, requestOptions); + } + + /** + * Update a topic. + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     title: String (Optional, Required on create)
+     *     createdAt: OffsetDateTime (Required)
+     *     createdBy: String (Required)
+     *     state: String(Normal/Archived/SoftDeleted) (Optional, Required on create)
+     *     conversationId: String (Required)
+     *     etag: String (Required)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     title: String (Optional, Required on create)
+     *     createdAt: OffsetDateTime (Required)
+     *     createdBy: String (Required)
+     *     state: String(Normal/Archived/SoftDeleted) (Optional, Required on create)
+     *     conversationId: String (Required)
+     *     etag: String (Required)
+     * }
+     * }
+     * 
+ * + *

Response Headers

+ * + * + * + * + *
Response Headers
NameTypeDescription
ETagStringThe entity tag for the response.
+ * + * @param roomId Room identifier. + * @param topicId Topic identifier unique within the room. + * @param resource The resource instance. + * @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. + * @return represents a chat topic in a room along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response updateTopicWithResponse(String roomId, String topicId, BinaryData resource, + RequestOptions requestOptions) { + return this.serviceClient.updateTopicWithResponse(roomId, topicId, resource, requestOptions); + } + + /** + * Soft delete a topic. + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param roomId Room identifier. + * @param topicId Topic identifier unique within the room. + * @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. + * @return the {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response deleteTopicWithResponse(String roomId, String topicId, RequestOptions requestOptions) { + return this.serviceClient.deleteTopicWithResponse(roomId, topicId, requestOptions); + } + + /** + * List all users with pagination. + *

Query Parameters

+ * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
maxpagesizeIntegerNoThe maximum number of result items per page.
continuationTokenStringNoContinuation token for pagination.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String(Human) (Required)
+     *     id: String (Required)
+     *     nickname: String (Required)
+     *     etag: String (Required)
+     * }
+     * }
+     * 
+ * + * @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. + * @return paged collection of ChatUser items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listUsers(RequestOptions requestOptions) { + return this.serviceClient.listUsers(requestOptions); + } + + /** + * List rooms for a user with pagination. + *

Query Parameters

+ * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
maxpagesizeIntegerNoThe maximum number of result items per page.
continuationTokenStringNoContinuation token for pagination.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     title: String (Required)
+     *     defaultConversation: String (Required)
+     *     etag: String (Required)
+     * }
+     * }
+     * 
+ * + * @param userId User identifier. + * @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. + * @return paged collection of ChatUserRoom items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listRoomsForUser(String userId, RequestOptions requestOptions) { + return this.serviceClient.listRoomsForUser(userId, requestOptions); + } + + /** + * List rooms with pagination. + * + * @param continuationToken Continuation token for pagination. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @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 paged collection of ChatRoom items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listRooms(String continuationToken) { + // Generated convenience method for listRooms + RequestOptions requestOptions = new RequestOptions(); + if (continuationToken != null) { + requestOptions.addQueryParam("continuationToken", continuationToken, false); + } + return serviceClient.listRooms(requestOptions).mapPage(bodyItemValue -> bodyItemValue.toObject(ChatRoom.class)); + } + + /** + * List rooms with pagination. + * + * @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 paged collection of ChatRoom items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listRooms() { + // Generated convenience method for listRooms + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.listRooms(requestOptions).mapPage(bodyItemValue -> bodyItemValue.toObject(ChatRoom.class)); + } + + /** + * List topics in a room with pagination. + * + * @param roomId Room identifier. + * @param continuationToken Continuation token for pagination. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @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 paged collection of ChatTopic items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listTopics(String roomId, String continuationToken) { + // Generated convenience method for listTopics + RequestOptions requestOptions = new RequestOptions(); + if (continuationToken != null) { + requestOptions.addQueryParam("continuationToken", continuationToken, false); + } + return serviceClient.listTopics(roomId, requestOptions) + .mapPage(bodyItemValue -> bodyItemValue.toObject(ChatTopic.class)); + } + + /** + * List topics in a room with pagination. + * + * @param roomId Room identifier. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @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 paged collection of ChatTopic items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listTopics(String roomId) { + // Generated convenience method for listTopics + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.listTopics(roomId, requestOptions) + .mapPage(bodyItemValue -> bodyItemValue.toObject(ChatTopic.class)); + } + + /** + * Create or replace a topic. + * + * Create or replace a topic with a client-specified ID. + * + * @param roomId Room identifier. + * @param topicId Topic identifier unique within the room. + * @param resource The resource instance. + * @param matchConditions Specifies HTTP options for conditional requests. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @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 represents a chat topic in a room. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public ChatTopic createOrReplaceTopic(String roomId, String topicId, ChatTopic resource, + MatchConditions matchConditions) { + // Generated convenience method for createOrReplaceTopicWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = matchConditions == null ? null : matchConditions.getIfMatch(); + String ifNoneMatch = matchConditions == null ? null : matchConditions.getIfNoneMatch(); + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + return createOrReplaceTopicWithResponse(roomId, topicId, BinaryData.fromObject(resource), requestOptions) + .getValue() + .toObject(ChatTopic.class); + } + + /** + * Create or replace a topic. + * + * Create or replace a topic with a client-specified ID. + * + * @param roomId Room identifier. + * @param topicId Topic identifier unique within the room. + * @param resource The resource instance. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @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 represents a chat topic in a room. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public ChatTopic createOrReplaceTopic(String roomId, String topicId, ChatTopic resource) { + // Generated convenience method for createOrReplaceTopicWithResponse + RequestOptions requestOptions = new RequestOptions(); + return createOrReplaceTopicWithResponse(roomId, topicId, BinaryData.fromObject(resource), requestOptions) + .getValue() + .toObject(ChatTopic.class); + } + + /** + * Get topic information. + * + * @param roomId Room identifier. + * @param topicId Topic identifier unique within the room. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @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 topic information. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public ChatTopic getTopic(String roomId, String topicId) { + // Generated convenience method for getTopicWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getTopicWithResponse(roomId, topicId, requestOptions).getValue().toObject(ChatTopic.class); + } + + /** + * Update a topic. + * + * @param roomId Room identifier. + * @param topicId Topic identifier unique within the room. + * @param resource The resource instance. + * @param matchConditions Specifies HTTP options for conditional requests. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @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 represents a chat topic in a room. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public ChatTopic updateTopic(String roomId, String topicId, ChatTopic resource, MatchConditions matchConditions) { + // Generated convenience method for updateTopicWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = matchConditions == null ? null : matchConditions.getIfMatch(); + String ifNoneMatch = matchConditions == null ? null : matchConditions.getIfNoneMatch(); + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + JsonMergePatchHelper.getChatTopicAccessor().prepareModelForJsonMergePatch(resource, true); + BinaryData resourceInBinaryData = BinaryData.fromObject(resource); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + resourceInBinaryData.getLength(); + JsonMergePatchHelper.getChatTopicAccessor().prepareModelForJsonMergePatch(resource, false); + return updateTopicWithResponse(roomId, topicId, resourceInBinaryData, requestOptions).getValue() + .toObject(ChatTopic.class); + } + + /** + * Update a topic. + * + * @param roomId Room identifier. + * @param topicId Topic identifier unique within the room. + * @param resource The resource instance. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @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 represents a chat topic in a room. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public ChatTopic updateTopic(String roomId, String topicId, ChatTopic resource) { + // Generated convenience method for updateTopicWithResponse + RequestOptions requestOptions = new RequestOptions(); + JsonMergePatchHelper.getChatTopicAccessor().prepareModelForJsonMergePatch(resource, true); + BinaryData resourceInBinaryData = BinaryData.fromObject(resource); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + resourceInBinaryData.getLength(); + JsonMergePatchHelper.getChatTopicAccessor().prepareModelForJsonMergePatch(resource, false); + return updateTopicWithResponse(roomId, topicId, resourceInBinaryData, requestOptions).getValue() + .toObject(ChatTopic.class); + } + + /** + * Soft delete a topic. + * + * @param roomId Room identifier. + * @param topicId Topic identifier unique within the room. + * @param matchConditions Specifies HTTP options for conditional requests. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void deleteTopic(String roomId, String topicId, MatchConditions matchConditions) { + // Generated convenience method for deleteTopicWithResponse + RequestOptions requestOptions = new RequestOptions(); + String ifMatch = matchConditions == null ? null : matchConditions.getIfMatch(); + String ifNoneMatch = matchConditions == null ? null : matchConditions.getIfNoneMatch(); + if (ifMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_MATCH, ifMatch); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + deleteTopicWithResponse(roomId, topicId, requestOptions).getValue(); + } + + /** + * Soft delete a topic. + * + * @param roomId Room identifier. + * @param topicId Topic identifier unique within the room. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @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. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void deleteTopic(String roomId, String topicId) { + // Generated convenience method for deleteTopicWithResponse + RequestOptions requestOptions = new RequestOptions(); + deleteTopicWithResponse(roomId, topicId, requestOptions).getValue(); + } + + /** + * List all users with pagination. + * + * @param continuationToken Continuation token for pagination. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @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 paged collection of ChatUser items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listUsers(String continuationToken) { + // Generated convenience method for listUsers + RequestOptions requestOptions = new RequestOptions(); + if (continuationToken != null) { + requestOptions.addQueryParam("continuationToken", continuationToken, false); + } + return serviceClient.listUsers(requestOptions).mapPage(bodyItemValue -> bodyItemValue.toObject(ChatUser.class)); + } + + /** + * List all users with pagination. + * + * @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 paged collection of ChatUser items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listUsers() { + // Generated convenience method for listUsers + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.listUsers(requestOptions).mapPage(bodyItemValue -> bodyItemValue.toObject(ChatUser.class)); + } + + /** + * List rooms for a user with pagination. + * + * @param userId User identifier. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @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 paged collection of ChatUserRoom items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listRoomsForUser(String userId) { + // Generated convenience method for listRoomsForUser + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.listRoomsForUser(userId, requestOptions) + .mapPage(bodyItemValue -> bodyItemValue.toObject(ChatUserRoom.class)); + } + + /** + * List rooms for a user with pagination. + * + * @param userId User identifier. + * @param continuationToken Continuation token for pagination. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @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 paged collection of ChatUserRoom items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listRoomsForUser(String userId, String continuationToken) { + // Generated convenience method for listRoomsForUser + RequestOptions requestOptions = new RequestOptions(); + if (continuationToken != null) { + requestOptions.addQueryParam("continuationToken", continuationToken, false); + } + return serviceClient.listRoomsForUser(userId, requestOptions) + .mapPage(bodyItemValue -> bodyItemValue.toObject(ChatUserRoom.class)); + } } diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceVersion.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceVersion.java index e91eac676d04a..1c1828fe08ef5 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceVersion.java +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceVersion.java @@ -13,7 +13,12 @@ public enum WebPubSubChatServiceVersion implements ServiceVersion { /** * Enum value 2026-02-01-preview. */ - V2026_02_01_PREVIEW("2026-02-01-preview"); + V2026_02_01_PREVIEW("2026-02-01-preview"), + + /** + * Enum value 2026-08-01-preview. + */ + V2026_08_01_PREVIEW("2026-08-01-preview"); private final String version; @@ -35,6 +40,6 @@ public String getVersion() { * @return The latest {@link WebPubSubChatServiceVersion}. */ public static WebPubSubChatServiceVersion getLatest() { - return V2026_02_01_PREVIEW; + return V2026_08_01_PREVIEW; } } diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/implementation/JsonMergePatchHelper.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/implementation/JsonMergePatchHelper.java index 011cf21169908..8c78ddb7e302c 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/implementation/JsonMergePatchHelper.java +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/implementation/JsonMergePatchHelper.java @@ -5,6 +5,7 @@ package com.azure.messaging.webpubsub.chat.implementation; import com.azure.messaging.webpubsub.chat.models.ChatMessage; +import com.azure.messaging.webpubsub.chat.models.ChatTopic; import com.azure.messaging.webpubsub.chat.models.MessageContent; /** @@ -42,4 +43,20 @@ public static void setMessageContentAccessor(MessageContentAccessor accessor) { public static MessageContentAccessor getMessageContentAccessor() { return messageContentAccessor; } + + private static ChatTopicAccessor chatTopicAccessor; + + public interface ChatTopicAccessor { + ChatTopic prepareModelForJsonMergePatch(ChatTopic chatTopic, boolean jsonMergePatchEnabled); + + boolean isJsonMergePatch(ChatTopic chatTopic); + } + + public static void setChatTopicAccessor(ChatTopicAccessor accessor) { + chatTopicAccessor = accessor; + } + + public static ChatTopicAccessor getChatTopicAccessor() { + return chatTopicAccessor; + } } diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/implementation/WebPubSubChatServiceClientImpl.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/implementation/WebPubSubChatServiceClientImpl.java index 34905314f70a0..a2a8f645b7db2 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/implementation/WebPubSubChatServiceClientImpl.java +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/implementation/WebPubSubChatServiceClientImpl.java @@ -361,6 +361,26 @@ Response deleteRoleSync(@HostParam("endpoint") String endpoint, @QueryParam("api-version") String apiVersion, @PathParam("hub") String hub, @PathParam("roleName") String roleName, RequestOptions requestOptions, Context context); + @Get("/api/hubs/{hub}/chat/rooms") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> listRooms(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("hub") String hub, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/api/hubs/{hub}/chat/rooms") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listRoomsSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("hub") String hub, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + @Put("/api/hubs/{hub}/chat/rooms/{roomId}") @ExpectedResponses({ 200, 201 }) @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) @@ -427,6 +447,122 @@ Response deleteRoomSync(@HostParam("endpoint") String endpoint, @QueryParam("api-version") String apiVersion, @PathParam("hub") String hub, @PathParam("roomId") String roomId, RequestOptions requestOptions, Context context); + @Get("/api/hubs/{hub}/chat/rooms/{roomId}/topics") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> listTopics(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("hub") String hub, + @PathParam("roomId") String roomId, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Get("/api/hubs/{hub}/chat/rooms/{roomId}/topics") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listTopicsSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("hub") String hub, + @PathParam("roomId") String roomId, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Put("/api/hubs/{hub}/chat/rooms/{roomId}/topics/{topicId}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> createOrReplaceTopic(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("hub") String hub, + @PathParam("roomId") String roomId, @PathParam("topicId") String topicId, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData resource, RequestOptions requestOptions, Context context); + + @Put("/api/hubs/{hub}/chat/rooms/{roomId}/topics/{topicId}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response createOrReplaceTopicSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("hub") String hub, + @PathParam("roomId") String roomId, @PathParam("topicId") String topicId, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData resource, RequestOptions requestOptions, Context context); + + @Get("/api/hubs/{hub}/chat/rooms/{roomId}/topics/{topicId}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getTopic(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("hub") String hub, + @PathParam("roomId") String roomId, @PathParam("topicId") String topicId, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/api/hubs/{hub}/chat/rooms/{roomId}/topics/{topicId}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getTopicSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("hub") String hub, + @PathParam("roomId") String roomId, @PathParam("topicId") String topicId, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Patch("/api/hubs/{hub}/chat/rooms/{roomId}/topics/{topicId}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> updateTopic(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("hub") String hub, + @PathParam("roomId") String roomId, @PathParam("topicId") String topicId, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/merge-patch+json") BinaryData resource, RequestOptions requestOptions, + Context context); + + @Patch("/api/hubs/{hub}/chat/rooms/{roomId}/topics/{topicId}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response updateTopicSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("hub") String hub, + @PathParam("roomId") String roomId, @PathParam("topicId") String topicId, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/merge-patch+json") BinaryData resource, RequestOptions requestOptions, + Context context); + + @Delete("/api/hubs/{hub}/chat/rooms/{roomId}/topics/{topicId}") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> deleteTopic(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("hub") String hub, + @PathParam("roomId") String roomId, @PathParam("topicId") String topicId, RequestOptions requestOptions, + Context context); + + @Delete("/api/hubs/{hub}/chat/rooms/{roomId}/topics/{topicId}") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response deleteTopicSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("hub") String hub, + @PathParam("roomId") String roomId, @PathParam("topicId") String topicId, RequestOptions requestOptions, + Context context); + @Get("/api/hubs/{hub}/chat/rooms/{roomId}/members") @ExpectedResponses({ 200 }) @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) @@ -495,6 +631,26 @@ Response deleteRoomMemberSync(@HostParam("endpoint") String endpoint, @PathParam("roomId") String roomId, @PathParam("userId") String userId, RequestOptions requestOptions, Context context); + @Get("/api/hubs/{hub}/chat/users") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> listUsers(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("hub") String hub, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/api/hubs/{hub}/chat/users") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listUsersSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("hub") String hub, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + @Get("/api/hubs/{hub}/chat/users/{userId}") @ExpectedResponses({ 200 }) @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) @@ -561,6 +717,28 @@ Response deleteUserSync(@HostParam("endpoint") String endpoint, @QueryParam("api-version") String apiVersion, @PathParam("hub") String hub, @PathParam("userId") String userId, RequestOptions requestOptions, Context context); + @Get("/api/hubs/{hub}/chat/users/{userId}/rooms") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> listRoomsForUser(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("hub") String hub, + @PathParam("userId") String userId, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Get("/api/hubs/{hub}/chat/users/{userId}/rooms") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listRoomsForUserSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("hub") String hub, + @PathParam("userId") String userId, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + @Post("/api/hubs/{hub}/:generateToken") @ExpectedResponses({ 200 }) @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) @@ -621,6 +799,46 @@ Response listRolesNextSync(@PathParam(value = "nextLink", encoded = @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> listRoomsNext(@PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listRoomsNextSync(@PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> listTopicsNext(@PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listTopicsNextSync(@PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + @Get("{nextLink}") @ExpectedResponses({ 200 }) @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) @@ -640,6 +858,46 @@ Mono> listRoomMembersNext(@PathParam(value = "nextLink", en Response listRoomMembersNextSync(@PathParam(value = "nextLink", encoded = true) String nextLink, @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> listUsersNext(@PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listUsersNextSync(@PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> listRoomsForUserNext(@PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listRoomsForUserNextSync(@PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); } /** @@ -1586,20 +1844,16 @@ public Response deleteRoleWithResponse(String roleName, RequestOptions req } /** - * Create or replace a room. - * - * Create or replace a room with a client-specified ID. - *

Header Parameters

+ * List rooms with pagination. + *

Query Parameters

* - * + * * - * - * + * + * *
Header ParametersQuery Parameters
NameTypeRequiredDescription
If-MatchStringNoThe request should only proceed if an entity matches this - * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this - * string.
maxpagesizeIntegerNoThe maximum number of result items per page.
continuationTokenStringNoContinuation token for pagination.
- * You can add these to a request with {@link RequestOptions#addHeader} - *

Request Body Schema

+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

* *
      * {@code
@@ -1611,7 +1865,35 @@ public Response deleteRoleWithResponse(String roleName, RequestOptions req
      * }
      * }
      * 
- * + * + * @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. + * @return paged collection of ChatRoom items along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listRoomsSinglePageAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listRooms(this.getEndpoint(), this.getServiceVersion().getVersion(), + this.getHub(), accept, requestOptions, context)) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null)); + } + + /** + * List rooms with pagination. + *

Query Parameters

+ * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
maxpagesizeIntegerNoThe maximum number of result items per page.
continuationTokenStringNoContinuation token for pagination.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} *

Response Body Schema

* *
@@ -1624,9 +1906,183 @@ public Response deleteRoleWithResponse(String roleName, RequestOptions req
      * }
      * }
      * 
- * - *

Response Headers

- * + * + * @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. + * @return paged collection of ChatRoom items as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listRoomsAsync(RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE); + return new PagedFlux<>((pageSize) -> { + RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions; + if (pageSize != null) { + requestOptionsLocal.addRequestCallback(requestLocal -> { + UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl()); + urlBuilder.setQueryParameter("maxpagesize", String.valueOf(pageSize)); + requestLocal.setUrl(urlBuilder.toString()); + }); + } + return listRoomsSinglePageAsync(requestOptionsLocal); + }, (nextLink, pageSize) -> { + RequestOptions requestOptionsLocal = new RequestOptions(); + requestOptionsLocal.setContext(requestOptionsForNextPage.getContext()); + if (pageSize != null) { + requestOptionsLocal.addRequestCallback(requestLocal -> { + UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl()); + urlBuilder.setQueryParameter("maxpagesize", String.valueOf(pageSize)); + requestLocal.setUrl(urlBuilder.toString()); + }); + } + return listRoomsNextSinglePageAsync(nextLink, requestOptionsLocal); + }); + } + + /** + * List rooms with pagination. + *

Query Parameters

+ *
+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
maxpagesizeIntegerNoThe maximum number of result items per page.
continuationTokenStringNoContinuation token for pagination.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     title: String (Required)
+     *     defaultConversation: String (Required)
+     *     etag: String (Required)
+     * }
+     * }
+     * 
+ * + * @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. + * @return paged collection of ChatRoom items along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listRoomsSinglePage(RequestOptions requestOptions) { + final String accept = "application/json"; + Response res = service.listRoomsSync(this.getEndpoint(), this.getServiceVersion().getVersion(), + this.getHub(), accept, requestOptions, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null); + } + + /** + * List rooms with pagination. + *

Query Parameters

+ * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
maxpagesizeIntegerNoThe maximum number of result items per page.
continuationTokenStringNoContinuation token for pagination.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     title: String (Required)
+     *     defaultConversation: String (Required)
+     *     etag: String (Required)
+     * }
+     * }
+     * 
+ * + * @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. + * @return paged collection of ChatRoom items as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listRooms(RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE); + return new PagedIterable<>((pageSize) -> { + RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions; + if (pageSize != null) { + requestOptionsLocal.addRequestCallback(requestLocal -> { + UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl()); + urlBuilder.setQueryParameter("maxpagesize", String.valueOf(pageSize)); + requestLocal.setUrl(urlBuilder.toString()); + }); + } + return listRoomsSinglePage(requestOptionsLocal); + }, (nextLink, pageSize) -> { + RequestOptions requestOptionsLocal = new RequestOptions(); + requestOptionsLocal.setContext(requestOptionsForNextPage.getContext()); + if (pageSize != null) { + requestOptionsLocal.addRequestCallback(requestLocal -> { + UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl()); + urlBuilder.setQueryParameter("maxpagesize", String.valueOf(pageSize)); + requestLocal.setUrl(urlBuilder.toString()); + }); + } + return listRoomsNextSinglePage(nextLink, requestOptionsLocal); + }); + } + + /** + * Create or replace a room. + * + * Create or replace a room with a client-specified ID. + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     title: String (Required)
+     *     defaultConversation: String (Required)
+     *     etag: String (Required)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     title: String (Required)
+     *     defaultConversation: String (Required)
+     *     etag: String (Required)
+     * }
+     * }
+     * 
+ * + *

Response Headers

+ * * * * @@ -1831,7 +2287,7 @@ public Response deleteRoomWithResponse(String roomId, RequestOptions reque } /** - * Get room members. + * List topics in a room with pagination. *

Query Parameters

*
Response Headers
NameTypeDescription
ETagStringThe entity tag for the response.
* @@ -1845,8 +2301,12 @@ public Response deleteRoomWithResponse(String roomId, RequestOptions reque *
      * {@code
      * {
-     *     userId: String (Required)
-     *     roleName: String (Required)
+     *     id: String (Required)
+     *     title: String (Optional, Required on create)
+     *     createdAt: OffsetDateTime (Required)
+     *     createdBy: String (Required)
+     *     state: String(Normal/Archived/SoftDeleted) (Optional, Required on create)
+     *     conversationId: String (Required)
      *     etag: String (Required)
      * }
      * }
@@ -1858,21 +2318,21 @@ public Response deleteRoomWithResponse(String roomId, RequestOptions reque
      * @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.
-     * @return room members along with {@link PagedResponse} on successful completion of {@link Mono}.
+     * @return paged collection of ChatTopic items along with {@link PagedResponse} on successful completion of
+     * {@link Mono}.
      */
     @ServiceMethod(returns = ReturnType.SINGLE)
-    private Mono> listRoomMembersSinglePageAsync(String roomId,
-        RequestOptions requestOptions) {
+    private Mono> listTopicsSinglePageAsync(String roomId, RequestOptions requestOptions) {
         final String accept = "application/json";
         return FluxUtil
-            .withContext(context -> service.listRoomMembers(this.getEndpoint(), this.getServiceVersion().getVersion(),
+            .withContext(context -> service.listTopics(this.getEndpoint(), this.getServiceVersion().getVersion(),
                 this.getHub(), roomId, accept, requestOptions, context))
             .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(),
                 getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null));
     }
 
     /**
-     * Get room members.
+     * List topics in a room with pagination.
      * 

Query Parameters

*
Query Parameters
* @@ -1886,8 +2346,12 @@ private Mono> listRoomMembersSinglePageAsync(String ro *
      * {@code
      * {
-     *     userId: String (Required)
-     *     roleName: String (Required)
+     *     id: String (Required)
+     *     title: String (Optional, Required on create)
+     *     createdAt: OffsetDateTime (Required)
+     *     createdBy: String (Required)
+     *     state: String(Normal/Archived/SoftDeleted) (Optional, Required on create)
+     *     conversationId: String (Required)
      *     etag: String (Required)
      * }
      * }
@@ -1899,10 +2363,10 @@ private Mono> listRoomMembersSinglePageAsync(String ro
      * @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.
-     * @return room members as paginated response with {@link PagedFlux}.
+     * @return paged collection of ChatTopic items as paginated response with {@link PagedFlux}.
      */
     @ServiceMethod(returns = ReturnType.COLLECTION)
-    public PagedFlux listRoomMembersAsync(String roomId, RequestOptions requestOptions) {
+    public PagedFlux listTopicsAsync(String roomId, RequestOptions requestOptions) {
         RequestOptions requestOptionsForNextPage = new RequestOptions();
         requestOptionsForNextPage.setContext(
             requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE);
@@ -1915,7 +2379,7 @@ public PagedFlux listRoomMembersAsync(String roomId, RequestOptions
                     requestLocal.setUrl(urlBuilder.toString());
                 });
             }
-            return listRoomMembersSinglePageAsync(roomId, requestOptionsLocal);
+            return listTopicsSinglePageAsync(roomId, requestOptionsLocal);
         }, (nextLink, pageSize) -> {
             RequestOptions requestOptionsLocal = new RequestOptions();
             requestOptionsLocal.setContext(requestOptionsForNextPage.getContext());
@@ -1926,12 +2390,12 @@ public PagedFlux listRoomMembersAsync(String roomId, RequestOptions
                     requestLocal.setUrl(urlBuilder.toString());
                 });
             }
-            return listRoomMembersNextSinglePageAsync(nextLink, requestOptionsLocal);
+            return listTopicsNextSinglePageAsync(nextLink, requestOptionsLocal);
         });
     }
 
     /**
-     * Get room members.
+     * List topics in a room with pagination.
      * 

Query Parameters

*
Query Parameters
* @@ -1945,8 +2409,12 @@ public PagedFlux listRoomMembersAsync(String roomId, RequestOptions *
      * {@code
      * {
-     *     userId: String (Required)
-     *     roleName: String (Required)
+     *     id: String (Required)
+     *     title: String (Optional, Required on create)
+     *     createdAt: OffsetDateTime (Required)
+     *     createdBy: String (Required)
+     *     state: String(Normal/Archived/SoftDeleted) (Optional, Required on create)
+     *     conversationId: String (Required)
      *     etag: String (Required)
      * }
      * }
@@ -1958,19 +2426,19 @@ public PagedFlux listRoomMembersAsync(String roomId, RequestOptions
      * @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.
-     * @return room members along with {@link PagedResponse}.
+     * @return paged collection of ChatTopic items along with {@link PagedResponse}.
      */
     @ServiceMethod(returns = ReturnType.SINGLE)
-    private PagedResponse listRoomMembersSinglePage(String roomId, RequestOptions requestOptions) {
+    private PagedResponse listTopicsSinglePage(String roomId, RequestOptions requestOptions) {
         final String accept = "application/json";
-        Response res = service.listRoomMembersSync(this.getEndpoint(),
-            this.getServiceVersion().getVersion(), this.getHub(), roomId, accept, requestOptions, Context.NONE);
+        Response res = service.listTopicsSync(this.getEndpoint(), this.getServiceVersion().getVersion(),
+            this.getHub(), roomId, accept, requestOptions, Context.NONE);
         return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(),
             getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null);
     }
 
     /**
-     * Get room members.
+     * List topics in a room with pagination.
      * 

Query Parameters

*
Query Parameters
* @@ -1984,8 +2452,12 @@ private PagedResponse listRoomMembersSinglePage(String roomId, Reque *
      * {@code
      * {
-     *     userId: String (Required)
-     *     roleName: String (Required)
+     *     id: String (Required)
+     *     title: String (Optional, Required on create)
+     *     createdAt: OffsetDateTime (Required)
+     *     createdBy: String (Required)
+     *     state: String(Normal/Archived/SoftDeleted) (Optional, Required on create)
+     *     conversationId: String (Required)
      *     etag: String (Required)
      * }
      * }
@@ -1997,10 +2469,10 @@ private PagedResponse listRoomMembersSinglePage(String roomId, Reque
      * @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.
-     * @return room members as paginated response with {@link PagedIterable}.
+     * @return paged collection of ChatTopic items as paginated response with {@link PagedIterable}.
      */
     @ServiceMethod(returns = ReturnType.COLLECTION)
-    public PagedIterable listRoomMembers(String roomId, RequestOptions requestOptions) {
+    public PagedIterable listTopics(String roomId, RequestOptions requestOptions) {
         RequestOptions requestOptionsForNextPage = new RequestOptions();
         requestOptionsForNextPage.setContext(
             requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE);
@@ -2013,7 +2485,7 @@ public PagedIterable listRoomMembers(String roomId, RequestOptions r
                     requestLocal.setUrl(urlBuilder.toString());
                 });
             }
-            return listRoomMembersSinglePage(roomId, requestOptionsLocal);
+            return listTopicsSinglePage(roomId, requestOptionsLocal);
         }, (nextLink, pageSize) -> {
             RequestOptions requestOptionsLocal = new RequestOptions();
             requestOptionsLocal.setContext(requestOptionsForNextPage.getContext());
@@ -2024,12 +2496,14 @@ public PagedIterable listRoomMembers(String roomId, RequestOptions r
                     requestLocal.setUrl(urlBuilder.toString());
                 });
             }
-            return listRoomMembersNextSinglePage(nextLink, requestOptionsLocal);
+            return listTopicsNextSinglePage(nextLink, requestOptionsLocal);
         });
     }
 
     /**
-     * Create or replace a room member.
+     * Create or replace a topic.
+     *
+     * Create or replace a topic with a client-specified ID.
      * 

Header Parameters

*
Query Parameters
* @@ -2045,8 +2519,12 @@ public PagedIterable listRoomMembers(String roomId, RequestOptions r *
      * {@code
      * {
-     *     userId: String (Required)
-     *     roleName: String (Required)
+     *     id: String (Required)
+     *     title: String (Optional, Required on create)
+     *     createdAt: OffsetDateTime (Required)
+     *     createdBy: String (Required)
+     *     state: String(Normal/Archived/SoftDeleted) (Optional, Required on create)
+     *     conversationId: String (Required)
      *     etag: String (Required)
      * }
      * }
@@ -2057,8 +2535,12 @@ public PagedIterable listRoomMembers(String roomId, RequestOptions r
      * 
      * {@code
      * {
-     *     userId: String (Required)
-     *     roleName: String (Required)
+     *     id: String (Required)
+     *     title: String (Optional, Required on create)
+     *     createdAt: OffsetDateTime (Required)
+     *     createdBy: String (Required)
+     *     state: String(Normal/Archived/SoftDeleted) (Optional, Required on create)
+     *     conversationId: String (Required)
      *     etag: String (Required)
      * }
      * }
@@ -2072,27 +2554,29 @@ public PagedIterable listRoomMembers(String roomId, RequestOptions r
      * 
Header Parameters
* * @param roomId Room identifier. - * @param userId User ID of the member. + * @param topicId Topic identifier unique within the room. * @param resource The resource instance. * @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. - * @return represents a room member along with {@link Response} on successful completion of {@link Mono}. + * @return represents a chat topic in a room along with {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> createOrReplaceRoomMemberWithResponseAsync(String roomId, String userId, + public Mono> createOrReplaceTopicWithResponseAsync(String roomId, String topicId, BinaryData resource, RequestOptions requestOptions) { final String contentType = "application/json"; final String accept = "application/json"; return FluxUtil.withContext( - context -> service.createOrReplaceRoomMember(this.getEndpoint(), this.getServiceVersion().getVersion(), - this.getHub(), roomId, userId, contentType, accept, resource, requestOptions, context)); + context -> service.createOrReplaceTopic(this.getEndpoint(), this.getServiceVersion().getVersion(), + this.getHub(), roomId, topicId, contentType, accept, resource, requestOptions, context)); } /** - * Create or replace a room member. + * Create or replace a topic. + * + * Create or replace a topic with a client-specified ID. *

Header Parameters

* * @@ -2108,8 +2592,12 @@ public Mono> createOrReplaceRoomMemberWithResponseAsync(Str *
      * {@code
      * {
-     *     userId: String (Required)
-     *     roleName: String (Required)
+     *     id: String (Required)
+     *     title: String (Optional, Required on create)
+     *     createdAt: OffsetDateTime (Required)
+     *     createdBy: String (Required)
+     *     state: String(Normal/Archived/SoftDeleted) (Optional, Required on create)
+     *     conversationId: String (Required)
      *     etag: String (Required)
      * }
      * }
@@ -2120,8 +2608,12 @@ public Mono> createOrReplaceRoomMemberWithResponseAsync(Str
      * 
      * {@code
      * {
-     *     userId: String (Required)
-     *     roleName: String (Required)
+     *     id: String (Required)
+     *     title: String (Optional, Required on create)
+     *     createdAt: OffsetDateTime (Required)
+     *     createdBy: String (Required)
+     *     state: String(Normal/Archived/SoftDeleted) (Optional, Required on create)
+     *     conversationId: String (Required)
      *     etag: String (Required)
      * }
      * }
@@ -2135,79 +2627,867 @@ public Mono> createOrReplaceRoomMemberWithResponseAsync(Str
      * 
Header Parameters
* * @param roomId Room identifier. - * @param userId User ID of the member. + * @param topicId Topic identifier unique within the room. * @param resource The resource instance. * @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. - * @return represents a room member along with {@link Response}. + * @return represents a chat topic in a room along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response createOrReplaceRoomMemberWithResponse(String roomId, String userId, BinaryData resource, + public Response createOrReplaceTopicWithResponse(String roomId, String topicId, BinaryData resource, RequestOptions requestOptions) { final String contentType = "application/json"; final String accept = "application/json"; - return service.createOrReplaceRoomMemberSync(this.getEndpoint(), this.getServiceVersion().getVersion(), - this.getHub(), roomId, userId, contentType, accept, resource, requestOptions, Context.NONE); + return service.createOrReplaceTopicSync(this.getEndpoint(), this.getServiceVersion().getVersion(), + this.getHub(), roomId, topicId, contentType, accept, resource, requestOptions, Context.NONE); } /** - * Delete a room member. - *

Header Parameters

- * - * - * - * - * - *
Header Parameters
NameTypeRequiredDescription
If-MatchStringNoThe request should only proceed if an entity matches this - * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this - * string.
- * You can add these to a request with {@link RequestOptions#addHeader} + * Get topic information. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     title: String (Optional, Required on create)
+     *     createdAt: OffsetDateTime (Required)
+     *     createdBy: String (Required)
+     *     state: String(Normal/Archived/SoftDeleted) (Optional, Required on create)
+     *     conversationId: String (Required)
+     *     etag: String (Required)
+     * }
+     * }
+     * 
* * @param roomId Room identifier. - * @param userId User ID of the member. + * @param topicId Topic identifier unique within the room. * @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. - * @return the {@link Response} on successful completion of {@link Mono}. + * @return topic information along with {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> deleteRoomMemberWithResponseAsync(String roomId, String userId, + public Mono> getTopicWithResponseAsync(String roomId, String topicId, + RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.getTopic(this.getEndpoint(), + this.getServiceVersion().getVersion(), this.getHub(), roomId, topicId, accept, requestOptions, context)); + } + + /** + * Get topic information. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     title: String (Optional, Required on create)
+     *     createdAt: OffsetDateTime (Required)
+     *     createdBy: String (Required)
+     *     state: String(Normal/Archived/SoftDeleted) (Optional, Required on create)
+     *     conversationId: String (Required)
+     *     etag: String (Required)
+     * }
+     * }
+     * 
+ * + * @param roomId Room identifier. + * @param topicId Topic identifier unique within the room. + * @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. + * @return topic information along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getTopicWithResponse(String roomId, String topicId, RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getTopicSync(this.getEndpoint(), this.getServiceVersion().getVersion(), this.getHub(), roomId, + topicId, accept, requestOptions, Context.NONE); + } + + /** + * Update a topic. + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     title: String (Optional, Required on create)
+     *     createdAt: OffsetDateTime (Required)
+     *     createdBy: String (Required)
+     *     state: String(Normal/Archived/SoftDeleted) (Optional, Required on create)
+     *     conversationId: String (Required)
+     *     etag: String (Required)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     title: String (Optional, Required on create)
+     *     createdAt: OffsetDateTime (Required)
+     *     createdBy: String (Required)
+     *     state: String(Normal/Archived/SoftDeleted) (Optional, Required on create)
+     *     conversationId: String (Required)
+     *     etag: String (Required)
+     * }
+     * }
+     * 
+ * + *

Response Headers

+ * + * + * + * + *
Response Headers
NameTypeDescription
ETagStringThe entity tag for the response.
+ * + * @param roomId Room identifier. + * @param topicId Topic identifier unique within the room. + * @param resource The resource instance. + * @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. + * @return represents a chat topic in a room along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> updateTopicWithResponseAsync(String roomId, String topicId, BinaryData resource, + RequestOptions requestOptions) { + final String contentType = "application/merge-patch+json"; + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.updateTopic(this.getEndpoint(), this.getServiceVersion().getVersion(), + this.getHub(), roomId, topicId, contentType, accept, resource, requestOptions, context)); + } + + /** + * Update a topic. + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     title: String (Optional, Required on create)
+     *     createdAt: OffsetDateTime (Required)
+     *     createdBy: String (Required)
+     *     state: String(Normal/Archived/SoftDeleted) (Optional, Required on create)
+     *     conversationId: String (Required)
+     *     etag: String (Required)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     title: String (Optional, Required on create)
+     *     createdAt: OffsetDateTime (Required)
+     *     createdBy: String (Required)
+     *     state: String(Normal/Archived/SoftDeleted) (Optional, Required on create)
+     *     conversationId: String (Required)
+     *     etag: String (Required)
+     * }
+     * }
+     * 
+ * + *

Response Headers

+ * + * + * + * + *
Response Headers
NameTypeDescription
ETagStringThe entity tag for the response.
+ * + * @param roomId Room identifier. + * @param topicId Topic identifier unique within the room. + * @param resource The resource instance. + * @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. + * @return represents a chat topic in a room along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response updateTopicWithResponse(String roomId, String topicId, BinaryData resource, + RequestOptions requestOptions) { + final String contentType = "application/merge-patch+json"; + final String accept = "application/json"; + return service.updateTopicSync(this.getEndpoint(), this.getServiceVersion().getVersion(), this.getHub(), roomId, + topicId, contentType, accept, resource, requestOptions, Context.NONE); + } + + /** + * Soft delete a topic. + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param roomId Room identifier. + * @param topicId Topic identifier unique within the room. + * @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. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> deleteTopicWithResponseAsync(String roomId, String topicId, + RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.deleteTopic(this.getEndpoint(), + this.getServiceVersion().getVersion(), this.getHub(), roomId, topicId, requestOptions, context)); + } + + /** + * Soft delete a topic. + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param roomId Room identifier. + * @param topicId Topic identifier unique within the room. + * @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. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response deleteTopicWithResponse(String roomId, String topicId, RequestOptions requestOptions) { + return service.deleteTopicSync(this.getEndpoint(), this.getServiceVersion().getVersion(), this.getHub(), roomId, + topicId, requestOptions, Context.NONE); + } + + /** + * Get room members. + *

Query Parameters

+ * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
maxpagesizeIntegerNoThe maximum number of result items per page.
continuationTokenStringNoContinuation token for pagination.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     userId: String (Required)
+     *     roleName: String (Required)
+     *     etag: String (Required)
+     * }
+     * }
+     * 
+ * + * @param roomId Room identifier. + * @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. + * @return room members along with {@link PagedResponse} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listRoomMembersSinglePageAsync(String roomId, + RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listRoomMembers(this.getEndpoint(), this.getServiceVersion().getVersion(), + this.getHub(), roomId, accept, requestOptions, context)) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null)); + } + + /** + * Get room members. + *

Query Parameters

+ * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
maxpagesizeIntegerNoThe maximum number of result items per page.
continuationTokenStringNoContinuation token for pagination.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     userId: String (Required)
+     *     roleName: String (Required)
+     *     etag: String (Required)
+     * }
+     * }
+     * 
+ * + * @param roomId Room identifier. + * @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. + * @return room members as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listRoomMembersAsync(String roomId, RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE); + return new PagedFlux<>((pageSize) -> { + RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions; + if (pageSize != null) { + requestOptionsLocal.addRequestCallback(requestLocal -> { + UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl()); + urlBuilder.setQueryParameter("maxpagesize", String.valueOf(pageSize)); + requestLocal.setUrl(urlBuilder.toString()); + }); + } + return listRoomMembersSinglePageAsync(roomId, requestOptionsLocal); + }, (nextLink, pageSize) -> { + RequestOptions requestOptionsLocal = new RequestOptions(); + requestOptionsLocal.setContext(requestOptionsForNextPage.getContext()); + if (pageSize != null) { + requestOptionsLocal.addRequestCallback(requestLocal -> { + UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl()); + urlBuilder.setQueryParameter("maxpagesize", String.valueOf(pageSize)); + requestLocal.setUrl(urlBuilder.toString()); + }); + } + return listRoomMembersNextSinglePageAsync(nextLink, requestOptionsLocal); + }); + } + + /** + * Get room members. + *

Query Parameters

+ * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
maxpagesizeIntegerNoThe maximum number of result items per page.
continuationTokenStringNoContinuation token for pagination.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     userId: String (Required)
+     *     roleName: String (Required)
+     *     etag: String (Required)
+     * }
+     * }
+     * 
+ * + * @param roomId Room identifier. + * @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. + * @return room members along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listRoomMembersSinglePage(String roomId, RequestOptions requestOptions) { + final String accept = "application/json"; + Response res = service.listRoomMembersSync(this.getEndpoint(), + this.getServiceVersion().getVersion(), this.getHub(), roomId, accept, requestOptions, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null); + } + + /** + * Get room members. + *

Query Parameters

+ * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
maxpagesizeIntegerNoThe maximum number of result items per page.
continuationTokenStringNoContinuation token for pagination.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     userId: String (Required)
+     *     roleName: String (Required)
+     *     etag: String (Required)
+     * }
+     * }
+     * 
+ * + * @param roomId Room identifier. + * @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. + * @return room members as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listRoomMembers(String roomId, RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE); + return new PagedIterable<>((pageSize) -> { + RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions; + if (pageSize != null) { + requestOptionsLocal.addRequestCallback(requestLocal -> { + UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl()); + urlBuilder.setQueryParameter("maxpagesize", String.valueOf(pageSize)); + requestLocal.setUrl(urlBuilder.toString()); + }); + } + return listRoomMembersSinglePage(roomId, requestOptionsLocal); + }, (nextLink, pageSize) -> { + RequestOptions requestOptionsLocal = new RequestOptions(); + requestOptionsLocal.setContext(requestOptionsForNextPage.getContext()); + if (pageSize != null) { + requestOptionsLocal.addRequestCallback(requestLocal -> { + UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl()); + urlBuilder.setQueryParameter("maxpagesize", String.valueOf(pageSize)); + requestLocal.setUrl(urlBuilder.toString()); + }); + } + return listRoomMembersNextSinglePage(nextLink, requestOptionsLocal); + }); + } + + /** + * Create or replace a room member. + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     userId: String (Required)
+     *     roleName: String (Required)
+     *     etag: String (Required)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     userId: String (Required)
+     *     roleName: String (Required)
+     *     etag: String (Required)
+     * }
+     * }
+     * 
+ * + *

Response Headers

+ * + * + * + * + *
Response Headers
NameTypeDescription
ETagStringThe entity tag for the response.
+ * + * @param roomId Room identifier. + * @param userId User ID of the member. + * @param resource The resource instance. + * @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. + * @return represents a room member along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> createOrReplaceRoomMemberWithResponseAsync(String roomId, String userId, + BinaryData resource, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext( + context -> service.createOrReplaceRoomMember(this.getEndpoint(), this.getServiceVersion().getVersion(), + this.getHub(), roomId, userId, contentType, accept, resource, requestOptions, context)); + } + + /** + * Create or replace a room member. + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     userId: String (Required)
+     *     roleName: String (Required)
+     *     etag: String (Required)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     userId: String (Required)
+     *     roleName: String (Required)
+     *     etag: String (Required)
+     * }
+     * }
+     * 
+ * + *

Response Headers

+ * + * + * + * + *
Response Headers
NameTypeDescription
ETagStringThe entity tag for the response.
+ * + * @param roomId Room identifier. + * @param userId User ID of the member. + * @param resource The resource instance. + * @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. + * @return represents a room member along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createOrReplaceRoomMemberWithResponse(String roomId, String userId, BinaryData resource, + RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.createOrReplaceRoomMemberSync(this.getEndpoint(), this.getServiceVersion().getVersion(), + this.getHub(), roomId, userId, contentType, accept, resource, requestOptions, Context.NONE); + } + + /** + * Delete a room member. + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param roomId Room identifier. + * @param userId User ID of the member. + * @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. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> deleteRoomMemberWithResponseAsync(String roomId, String userId, RequestOptions requestOptions) { return FluxUtil.withContext(context -> service.deleteRoomMember(this.getEndpoint(), this.getServiceVersion().getVersion(), this.getHub(), roomId, userId, requestOptions, context)); } /** - * Delete a room member. - *

Header Parameters

+ * Delete a room member. + *

Header Parameters

+ * + * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
If-MatchStringNoThe request should only proceed if an entity matches this + * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this + * string.
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param roomId Room identifier. + * @param userId User ID of the member. + * @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. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response deleteRoomMemberWithResponse(String roomId, String userId, RequestOptions requestOptions) { + return service.deleteRoomMemberSync(this.getEndpoint(), this.getServiceVersion().getVersion(), this.getHub(), + roomId, userId, requestOptions, Context.NONE); + } + + /** + * List all users with pagination. + *

Query Parameters

+ * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
maxpagesizeIntegerNoThe maximum number of result items per page.
continuationTokenStringNoContinuation token for pagination.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String(Human) (Required)
+     *     id: String (Required)
+     *     nickname: String (Required)
+     *     etag: String (Required)
+     * }
+     * }
+     * 
+ * + * @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. + * @return paged collection of ChatUser items along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listUsersSinglePageAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listUsers(this.getEndpoint(), this.getServiceVersion().getVersion(), + this.getHub(), accept, requestOptions, context)) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null)); + } + + /** + * List all users with pagination. + *

Query Parameters

+ * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
maxpagesizeIntegerNoThe maximum number of result items per page.
continuationTokenStringNoContinuation token for pagination.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String(Human) (Required)
+     *     id: String (Required)
+     *     nickname: String (Required)
+     *     etag: String (Required)
+     * }
+     * }
+     * 
+ * + * @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. + * @return paged collection of ChatUser items as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listUsersAsync(RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE); + return new PagedFlux<>((pageSize) -> { + RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions; + if (pageSize != null) { + requestOptionsLocal.addRequestCallback(requestLocal -> { + UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl()); + urlBuilder.setQueryParameter("maxpagesize", String.valueOf(pageSize)); + requestLocal.setUrl(urlBuilder.toString()); + }); + } + return listUsersSinglePageAsync(requestOptionsLocal); + }, (nextLink, pageSize) -> { + RequestOptions requestOptionsLocal = new RequestOptions(); + requestOptionsLocal.setContext(requestOptionsForNextPage.getContext()); + if (pageSize != null) { + requestOptionsLocal.addRequestCallback(requestLocal -> { + UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl()); + urlBuilder.setQueryParameter("maxpagesize", String.valueOf(pageSize)); + requestLocal.setUrl(urlBuilder.toString()); + }); + } + return listUsersNextSinglePageAsync(nextLink, requestOptionsLocal); + }); + } + + /** + * List all users with pagination. + *

Query Parameters

+ * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
maxpagesizeIntegerNoThe maximum number of result items per page.
continuationTokenStringNoContinuation token for pagination.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String(Human) (Required)
+     *     id: String (Required)
+     *     nickname: String (Required)
+     *     etag: String (Required)
+     * }
+     * }
+     * 
+ * + * @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. + * @return paged collection of ChatUser items along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listUsersSinglePage(RequestOptions requestOptions) { + final String accept = "application/json"; + Response res = service.listUsersSync(this.getEndpoint(), this.getServiceVersion().getVersion(), + this.getHub(), accept, requestOptions, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null); + } + + /** + * List all users with pagination. + *

Query Parameters

* - * + * * - * - * + * + * *
Header ParametersQuery Parameters
NameTypeRequiredDescription
If-MatchStringNoThe request should only proceed if an entity matches this - * string.
If-None-MatchStringNoThe request should only proceed if no entity matches this - * string.
maxpagesizeIntegerNoThe maximum number of result items per page.
continuationTokenStringNoContinuation token for pagination.
- * You can add these to a request with {@link RequestOptions#addHeader} + * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String(Human) (Required)
+     *     id: String (Required)
+     *     nickname: String (Required)
+     *     etag: String (Required)
+     * }
+     * }
+     * 
* - * @param roomId Room identifier. - * @param userId User ID of the member. * @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. - * @return the {@link Response}. + * @return paged collection of ChatUser items as paginated response with {@link PagedIterable}. */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response deleteRoomMemberWithResponse(String roomId, String userId, RequestOptions requestOptions) { - return service.deleteRoomMemberSync(this.getEndpoint(), this.getServiceVersion().getVersion(), this.getHub(), - roomId, userId, requestOptions, Context.NONE); + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listUsers(RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE); + return new PagedIterable<>((pageSize) -> { + RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions; + if (pageSize != null) { + requestOptionsLocal.addRequestCallback(requestLocal -> { + UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl()); + urlBuilder.setQueryParameter("maxpagesize", String.valueOf(pageSize)); + requestLocal.setUrl(urlBuilder.toString()); + }); + } + return listUsersSinglePage(requestOptionsLocal); + }, (nextLink, pageSize) -> { + RequestOptions requestOptionsLocal = new RequestOptions(); + requestOptionsLocal.setContext(requestOptionsForNextPage.getContext()); + if (pageSize != null) { + requestOptionsLocal.addRequestCallback(requestLocal -> { + UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl()); + urlBuilder.setQueryParameter("maxpagesize", String.valueOf(pageSize)); + requestLocal.setUrl(urlBuilder.toString()); + }); + } + return listUsersNextSinglePage(nextLink, requestOptionsLocal); + }); } /** @@ -2468,6 +3748,209 @@ public Response deleteUserWithResponse(String userId, RequestOptions reque requestOptions, Context.NONE); } + /** + * List rooms for a user with pagination. + *

Query Parameters

+ * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
maxpagesizeIntegerNoThe maximum number of result items per page.
continuationTokenStringNoContinuation token for pagination.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     title: String (Required)
+     *     defaultConversation: String (Required)
+     *     etag: String (Required)
+     * }
+     * }
+     * 
+ * + * @param userId User identifier. + * @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. + * @return paged collection of ChatUserRoom items along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listRoomsForUserSinglePageAsync(String userId, + RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listRoomsForUser(this.getEndpoint(), this.getServiceVersion().getVersion(), + this.getHub(), userId, accept, requestOptions, context)) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null)); + } + + /** + * List rooms for a user with pagination. + *

Query Parameters

+ * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
maxpagesizeIntegerNoThe maximum number of result items per page.
continuationTokenStringNoContinuation token for pagination.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     title: String (Required)
+     *     defaultConversation: String (Required)
+     *     etag: String (Required)
+     * }
+     * }
+     * 
+ * + * @param userId User identifier. + * @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. + * @return paged collection of ChatUserRoom items as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listRoomsForUserAsync(String userId, RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE); + return new PagedFlux<>((pageSize) -> { + RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions; + if (pageSize != null) { + requestOptionsLocal.addRequestCallback(requestLocal -> { + UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl()); + urlBuilder.setQueryParameter("maxpagesize", String.valueOf(pageSize)); + requestLocal.setUrl(urlBuilder.toString()); + }); + } + return listRoomsForUserSinglePageAsync(userId, requestOptionsLocal); + }, (nextLink, pageSize) -> { + RequestOptions requestOptionsLocal = new RequestOptions(); + requestOptionsLocal.setContext(requestOptionsForNextPage.getContext()); + if (pageSize != null) { + requestOptionsLocal.addRequestCallback(requestLocal -> { + UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl()); + urlBuilder.setQueryParameter("maxpagesize", String.valueOf(pageSize)); + requestLocal.setUrl(urlBuilder.toString()); + }); + } + return listRoomsForUserNextSinglePageAsync(nextLink, requestOptionsLocal); + }); + } + + /** + * List rooms for a user with pagination. + *

Query Parameters

+ * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
maxpagesizeIntegerNoThe maximum number of result items per page.
continuationTokenStringNoContinuation token for pagination.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     title: String (Required)
+     *     defaultConversation: String (Required)
+     *     etag: String (Required)
+     * }
+     * }
+     * 
+ * + * @param userId User identifier. + * @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. + * @return paged collection of ChatUserRoom items along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listRoomsForUserSinglePage(String userId, RequestOptions requestOptions) { + final String accept = "application/json"; + Response res = service.listRoomsForUserSync(this.getEndpoint(), + this.getServiceVersion().getVersion(), this.getHub(), userId, accept, requestOptions, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null); + } + + /** + * List rooms for a user with pagination. + *

Query Parameters

+ * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
maxpagesizeIntegerNoThe maximum number of result items per page.
continuationTokenStringNoContinuation token for pagination.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     title: String (Required)
+     *     defaultConversation: String (Required)
+     *     etag: String (Required)
+     * }
+     * }
+     * 
+ * + * @param userId User identifier. + * @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. + * @return paged collection of ChatUserRoom items as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listRoomsForUser(String userId, RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE); + return new PagedIterable<>((pageSize) -> { + RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions; + if (pageSize != null) { + requestOptionsLocal.addRequestCallback(requestLocal -> { + UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl()); + urlBuilder.setQueryParameter("maxpagesize", String.valueOf(pageSize)); + requestLocal.setUrl(urlBuilder.toString()); + }); + } + return listRoomsForUserSinglePage(userId, requestOptionsLocal); + }, (nextLink, pageSize) -> { + RequestOptions requestOptionsLocal = new RequestOptions(); + requestOptionsLocal.setContext(requestOptionsForNextPage.getContext()); + if (pageSize != null) { + requestOptionsLocal.addRequestCallback(requestLocal -> { + UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl()); + urlBuilder.setQueryParameter("maxpagesize", String.valueOf(pageSize)); + requestLocal.setUrl(urlBuilder.toString()); + }); + } + return listRoomsForUserNextSinglePage(nextLink, requestOptionsLocal); + }); + } + /** * Generate a token for connecting a client to Azure Web PubSub. *

Query Parameters

@@ -2697,6 +4180,154 @@ private PagedResponse listRolesNextSinglePage(String nextLink, Reque getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null); } + /** + * List rooms with pagination. + * + * Get the next page of items. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     title: String (Required)
+     *     defaultConversation: String (Required)
+     *     etag: String (Required)
+     * }
+     * }
+     * 
+ * + * @param nextLink The URL to get the next list of items. + * @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. + * @return paged collection of ChatRoom items along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listRoomsNextSinglePageAsync(String nextLink, + RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> service.listRoomsNext(nextLink, this.getEndpoint(), accept, requestOptions, context)) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null)); + } + + /** + * List rooms with pagination. + * + * Get the next page of items. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     title: String (Required)
+     *     defaultConversation: String (Required)
+     *     etag: String (Required)
+     * }
+     * }
+     * 
+ * + * @param nextLink The URL to get the next list of items. + * @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. + * @return paged collection of ChatRoom items along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listRoomsNextSinglePage(String nextLink, RequestOptions requestOptions) { + final String accept = "application/json"; + Response res + = service.listRoomsNextSync(nextLink, this.getEndpoint(), accept, requestOptions, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null); + } + + /** + * List topics in a room with pagination. + * + * Get the next page of items. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     title: String (Optional, Required on create)
+     *     createdAt: OffsetDateTime (Required)
+     *     createdBy: String (Required)
+     *     state: String(Normal/Archived/SoftDeleted) (Optional, Required on create)
+     *     conversationId: String (Required)
+     *     etag: String (Required)
+     * }
+     * }
+     * 
+ * + * @param nextLink The URL to get the next list of items. + * @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. + * @return paged collection of ChatTopic items along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listTopicsNextSinglePageAsync(String nextLink, + RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> service.listTopicsNext(nextLink, this.getEndpoint(), accept, requestOptions, context)) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null)); + } + + /** + * List topics in a room with pagination. + * + * Get the next page of items. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     title: String (Optional, Required on create)
+     *     createdAt: OffsetDateTime (Required)
+     *     createdBy: String (Required)
+     *     state: String(Normal/Archived/SoftDeleted) (Optional, Required on create)
+     *     conversationId: String (Required)
+     *     etag: String (Required)
+     * }
+     * }
+     * 
+ * + * @param nextLink The URL to get the next list of items. + * @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. + * @return paged collection of ChatTopic items along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listTopicsNextSinglePage(String nextLink, RequestOptions requestOptions) { + final String accept = "application/json"; + Response res + = service.listTopicsNextSync(nextLink, this.getEndpoint(), accept, requestOptions, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null); + } + /** * Get room members. * @@ -2765,6 +4396,148 @@ private PagedResponse listRoomMembersNextSinglePage(String nextLink, getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null); } + /** + * List all users with pagination. + * + * Get the next page of items. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String(Human) (Required)
+     *     id: String (Required)
+     *     nickname: String (Required)
+     *     etag: String (Required)
+     * }
+     * }
+     * 
+ * + * @param nextLink The URL to get the next list of items. + * @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. + * @return paged collection of ChatUser items along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listUsersNextSinglePageAsync(String nextLink, + RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> service.listUsersNext(nextLink, this.getEndpoint(), accept, requestOptions, context)) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null)); + } + + /** + * List all users with pagination. + * + * Get the next page of items. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String(Human) (Required)
+     *     id: String (Required)
+     *     nickname: String (Required)
+     *     etag: String (Required)
+     * }
+     * }
+     * 
+ * + * @param nextLink The URL to get the next list of items. + * @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. + * @return paged collection of ChatUser items along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listUsersNextSinglePage(String nextLink, RequestOptions requestOptions) { + final String accept = "application/json"; + Response res + = service.listUsersNextSync(nextLink, this.getEndpoint(), accept, requestOptions, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null); + } + + /** + * List rooms for a user with pagination. + * + * Get the next page of items. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     title: String (Required)
+     *     defaultConversation: String (Required)
+     *     etag: String (Required)
+     * }
+     * }
+     * 
+ * + * @param nextLink The URL to get the next list of items. + * @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. + * @return paged collection of ChatUserRoom items along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listRoomsForUserNextSinglePageAsync(String nextLink, + RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> service.listRoomsForUserNext(nextLink, this.getEndpoint(), accept, requestOptions, context)) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null)); + } + + /** + * List rooms for a user with pagination. + * + * Get the next page of items. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     title: String (Required)
+     *     defaultConversation: String (Required)
+     *     etag: String (Required)
+     * }
+     * }
+     * 
+ * + * @param nextLink The URL to get the next list of items. + * @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. + * @return paged collection of ChatUserRoom items along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listRoomsForUserNextSinglePage(String nextLink, RequestOptions requestOptions) { + final String accept = "application/json"; + Response res + = service.listRoomsForUserNextSync(nextLink, this.getEndpoint(), accept, requestOptions, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null); + } + private List getValues(BinaryData binaryData, String... path) { try { Object value = binaryData.toObject(Map.class); diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/ChatTopic.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/ChatTopic.java new file mode 100644 index 0000000000000..d817e95e3f586 --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/ChatTopic.java @@ -0,0 +1,276 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.messaging.webpubsub.chat.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.core.util.CoreUtils; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.messaging.webpubsub.chat.implementation.JsonMergePatchHelper; +import java.io.IOException; +import java.time.OffsetDateTime; +import java.util.HashSet; +import java.util.Set; + +/** + * Represents a chat topic in a room. + */ +@Fluent +public final class ChatTopic implements JsonSerializable { + + /* + * Topic identifier unique within the room. + */ + @Generated + private String id; + + /* + * Topic title. + */ + @Generated + private String title; + + /* + * Timestamp when the topic was created. + */ + @Generated + private OffsetDateTime createdAt; + + /* + * User who created the topic. + */ + @Generated + private String createdBy; + + /* + * Current lifecycle state of the topic. + */ + @Generated + private ChatTopicState state; + + /* + * Conversation associated with this topic. + */ + @Generated + private String conversationId; + + /* + * The entity tag for this resource. + */ + @Generated + private String etag; + + /** + * Stores updated model property, the value is property name, not serialized name. + */ + @Generated + private final Set updatedProperties = new HashSet<>(); + + @Generated + private boolean jsonMergePatch; + + @Generated + private void serializeAsJsonMergePatch(boolean jsonMergePatch) { + this.jsonMergePatch = jsonMergePatch; + } + + static { + JsonMergePatchHelper.setChatTopicAccessor(new JsonMergePatchHelper.ChatTopicAccessor() { + + @Override + public ChatTopic prepareModelForJsonMergePatch(ChatTopic model, boolean jsonMergePatchEnabled) { + model.serializeAsJsonMergePatch(jsonMergePatchEnabled); + return model; + } + + @Override + public boolean isJsonMergePatch(ChatTopic model) { + return model.jsonMergePatch; + } + }); + } + + /** + * Creates an instance of ChatTopic class. + */ + @Generated + public ChatTopic() { + } + + /** + * Get the id property: Topic identifier unique within the room. + * + * @return the id value. + */ + @Generated + public String getId() { + return this.id; + } + + /** + * Get the title property: Topic title. + * + * @return the title value. + */ + @Generated + public String getTitle() { + return this.title; + } + + /** + * Set the title property: Topic title. + *

Required when create the resource.

+ * + * @param title the title value to set. + * @return the ChatTopic object itself. + */ + @Generated + public ChatTopic setTitle(String title) { + this.title = title; + this.updatedProperties.add("title"); + return this; + } + + /** + * Get the createdAt property: Timestamp when the topic was created. + * + * @return the createdAt value. + */ + @Generated + public OffsetDateTime getCreatedAt() { + return this.createdAt; + } + + /** + * Get the createdBy property: User who created the topic. + * + * @return the createdBy value. + */ + @Generated + public String getCreatedBy() { + return this.createdBy; + } + + /** + * Get the state property: Current lifecycle state of the topic. + * + * @return the state value. + */ + @Generated + public ChatTopicState getState() { + return this.state; + } + + /** + * Set the state property: Current lifecycle state of the topic. + *

Required when create the resource.

+ * + * @param state the state value to set. + * @return the ChatTopic object itself. + */ + @Generated + public ChatTopic setState(ChatTopicState state) { + this.state = state; + this.updatedProperties.add("state"); + return this; + } + + /** + * Get the conversationId property: Conversation associated with this topic. + * + * @return the conversationId value. + */ + @Generated + public String getConversationId() { + return this.conversationId; + } + + /** + * Get the etag property: The entity tag for this resource. + * + * @return the etag value. + */ + @Generated + public String getEtag() { + return this.etag; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + if (jsonMergePatch) { + return toJsonMergePatch(jsonWriter); + } else { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("title", this.title); + jsonWriter.writeStringField("state", this.state == null ? null : this.state.toString()); + return jsonWriter.writeEndObject(); + } + } + + @Generated + private JsonWriter toJsonMergePatch(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + if (updatedProperties.contains("title")) { + if (this.title == null) { + jsonWriter.writeNullField("title"); + } else { + jsonWriter.writeStringField("title", this.title); + } + } + if (updatedProperties.contains("state")) { + if (this.state == null) { + jsonWriter.writeNullField("state"); + } else { + jsonWriter.writeStringField("state", this.state.toString()); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ChatTopic from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ChatTopic if the JsonReader was pointing to an instance of it, or null if it was pointing + * to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ChatTopic. + */ + @Generated + public static ChatTopic fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ChatTopic deserializedChatTopic = new ChatTopic(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("id".equals(fieldName)) { + deserializedChatTopic.id = reader.getString(); + } else if ("createdAt".equals(fieldName)) { + deserializedChatTopic.createdAt = reader + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())); + } else if ("createdBy".equals(fieldName)) { + deserializedChatTopic.createdBy = reader.getString(); + } else if ("conversationId".equals(fieldName)) { + deserializedChatTopic.conversationId = reader.getString(); + } else if ("etag".equals(fieldName)) { + deserializedChatTopic.etag = reader.getString(); + } else if ("title".equals(fieldName)) { + deserializedChatTopic.title = reader.getString(); + } else if ("state".equals(fieldName)) { + deserializedChatTopic.state = ChatTopicState.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + return deserializedChatTopic; + }); + } +} diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/ChatTopicState.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/ChatTopicState.java new file mode 100644 index 0000000000000..93ff188687a6c --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/ChatTopicState.java @@ -0,0 +1,63 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.messaging.webpubsub.chat.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * The lifecycle state of a chat topic. + */ +public final class ChatTopicState extends ExpandableStringEnum { + + /** + * The topic is active. + */ + @Generated + public static final ChatTopicState NORMAL = fromString("Normal"); + + /** + * The topic is archived. + */ + @Generated + public static final ChatTopicState ARCHIVED = fromString("Archived"); + + /** + * The topic has been soft deleted. + */ + @Generated + public static final ChatTopicState SOFT_DELETED = fromString("SoftDeleted"); + + /** + * Creates a new instance of ChatTopicState value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public ChatTopicState() { + } + + /** + * Creates or finds a ChatTopicState from its string representation. + * + * @param name a name to look for. + * @return the corresponding ChatTopicState. + */ + @Generated + public static ChatTopicState fromString(String name) { + return fromString(name, ChatTopicState.class); + } + + /** + * Gets known ChatTopicState values. + * + * @return known ChatTopicState values. + */ + @Generated + public static Collection values() { + return values(ChatTopicState.class); + } +} diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/ChatUserRoom.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/ChatUserRoom.java new file mode 100644 index 0000000000000..d663164a812a4 --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/ChatUserRoom.java @@ -0,0 +1,147 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.messaging.webpubsub.chat.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Represents a read-only room projection used to list rooms associated with a user. + * This model enables the standard resource operation to derive the + * `/api/hubs/{hub}/chat/users/{userId}/rooms` collection path because + * `ChatRoom` is a child of `Hub`, not `ChatUser`. + * This model does not define an independent room lifecycle. + */ +@Immutable +public final class ChatUserRoom implements JsonSerializable { + + /* + * Room identifier. + */ + @Generated + private String id; + + /* + * Room title. + */ + @Generated + private final String title; + + /* + * Default conversation ID for this room. + */ + @Generated + private String defaultConversation; + + /* + * The entity tag for this resource. + */ + @Generated + private String etag; + + /** + * Creates an instance of ChatUserRoom class. + * + * @param title the title value to set. + */ + @Generated + private ChatUserRoom(String title) { + this.title = title; + } + + /** + * Get the id property: Room identifier. + * + * @return the id value. + */ + @Generated + public String getId() { + return this.id; + } + + /** + * Get the title property: Room title. + * + * @return the title value. + */ + @Generated + public String getTitle() { + return this.title; + } + + /** + * Get the defaultConversation property: Default conversation ID for this room. + * + * @return the defaultConversation value. + */ + @Generated + public String getDefaultConversation() { + return this.defaultConversation; + } + + /** + * Get the etag property: The entity tag for this resource. + * + * @return the etag value. + */ + @Generated + public String getEtag() { + return this.etag; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("title", this.title); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ChatUserRoom from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ChatUserRoom if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ChatUserRoom. + */ + @Generated + public static ChatUserRoom fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String id = null; + String title = null; + String defaultConversation = null; + String etag = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("id".equals(fieldName)) { + id = reader.getString(); + } else if ("title".equals(fieldName)) { + title = reader.getString(); + } else if ("defaultConversation".equals(fieldName)) { + defaultConversation = reader.getString(); + } else if ("etag".equals(fieldName)) { + etag = reader.getString(); + } else { + reader.skipChildren(); + } + } + ChatUserRoom deserializedChatUserRoom = new ChatUserRoom(title); + deserializedChatUserRoom.id = id; + deserializedChatUserRoom.defaultConversation = defaultConversation; + deserializedChatUserRoom.etag = etag; + return deserializedChatUserRoom; + }); + } +} diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/resources/META-INF/azure-messaging-webpubsub-chat_metadata.json b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/resources/META-INF/azure-messaging-webpubsub-chat_metadata.json index 37148d54c445b..6947686b8ae8a 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/resources/META-INF/azure-messaging-webpubsub-chat_metadata.json +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/resources/META-INF/azure-messaging-webpubsub-chat_metadata.json @@ -1 +1 @@ -{"flavor":"azure","apiVersions":{"WebPubSubChat":"2026-02-01-preview"},"crossLanguagePackageId":"WebPubSubChat","crossLanguageVersion":"c5f8f936d02a","crossLanguageDefinitions":{"com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient":"Customizations.WebPubSubChatServiceClient","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceRole":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceRoleWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceRoom":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceRoomMember":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoomMember","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceRoomMemberWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoomMember","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceRoomWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceUser":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceUserWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteMessage":"WebPubSubChat.WebPubSubChatServiceClient.deleteMessage","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteMessageWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteMessage","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteRole":"WebPubSubChat.WebPubSubChatServiceClient.deleteRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteRoleWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteRoom":"WebPubSubChat.WebPubSubChatServiceClient.deleteRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteRoomMember":"WebPubSubChat.WebPubSubChatServiceClient.deleteRoomMember","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteRoomMemberWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteRoomMember","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteRoomWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteUser":"WebPubSubChat.WebPubSubChatServiceClient.deleteUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteUserWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.generateClientToken":"Customizations.WebPubSubChatServiceClient.generateClientToken","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.generateClientTokenWithResponse":"Customizations.WebPubSubChatServiceClient.generateClientToken","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getConversation":"WebPubSubChat.WebPubSubChatServiceClient.getConversation","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getConversationWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getConversation","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getRole":"WebPubSubChat.WebPubSubChatServiceClient.getRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getRoleWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getRoom":"WebPubSubChat.WebPubSubChatServiceClient.getRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getRoomWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getUser":"WebPubSubChat.WebPubSubChatServiceClient.getUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getUserWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.listMessages":"WebPubSubChat.WebPubSubChatServiceClient.listMessages","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.listRoles":"WebPubSubChat.WebPubSubChatServiceClient.listRoles","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.listRoomMembers":"WebPubSubChat.WebPubSubChatServiceClient.listRoomMembers","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.updateMessage":"WebPubSubChat.WebPubSubChatServiceClient.updateMessage","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.updateMessageWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.updateMessage","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient":"Customizations.WebPubSubChatServiceClient","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceRole":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceRoleWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceRoom":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceRoomMember":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoomMember","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceRoomMemberWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoomMember","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceRoomWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceUser":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceUserWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteMessage":"WebPubSubChat.WebPubSubChatServiceClient.deleteMessage","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteMessageWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteMessage","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteRole":"WebPubSubChat.WebPubSubChatServiceClient.deleteRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteRoleWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteRoom":"WebPubSubChat.WebPubSubChatServiceClient.deleteRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteRoomMember":"WebPubSubChat.WebPubSubChatServiceClient.deleteRoomMember","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteRoomMemberWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteRoomMember","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteRoomWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteUser":"WebPubSubChat.WebPubSubChatServiceClient.deleteUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteUserWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.generateClientToken":"Customizations.WebPubSubChatServiceClient.generateClientToken","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.generateClientTokenWithResponse":"Customizations.WebPubSubChatServiceClient.generateClientToken","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getConversation":"WebPubSubChat.WebPubSubChatServiceClient.getConversation","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getConversationWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getConversation","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getRole":"WebPubSubChat.WebPubSubChatServiceClient.getRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getRoleWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getRoom":"WebPubSubChat.WebPubSubChatServiceClient.getRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getRoomWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getUser":"WebPubSubChat.WebPubSubChatServiceClient.getUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getUserWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.listMessages":"WebPubSubChat.WebPubSubChatServiceClient.listMessages","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.listRoles":"WebPubSubChat.WebPubSubChatServiceClient.listRoles","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.listRoomMembers":"WebPubSubChat.WebPubSubChatServiceClient.listRoomMembers","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.updateMessage":"WebPubSubChat.WebPubSubChatServiceClient.updateMessage","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.updateMessageWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.updateMessage","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClientBuilder":"Customizations.WebPubSubChatServiceClient","com.azure.messaging.webpubsub.chat.implementation.models.GenerateClientTokenResponse":"Customizations.GenerateClientTokenResponse","com.azure.messaging.webpubsub.chat.models.ChatConversation":"WebPubSubChat.ChatConversation","com.azure.messaging.webpubsub.chat.models.ChatMessage":"WebPubSubChat.ChatMessage","com.azure.messaging.webpubsub.chat.models.ChatPermission":"WebPubSubChat.ChatPermission","com.azure.messaging.webpubsub.chat.models.ChatRole":"WebPubSubChat.ChatRole","com.azure.messaging.webpubsub.chat.models.ChatRoom":"WebPubSubChat.ChatRoom","com.azure.messaging.webpubsub.chat.models.ChatRoomMember":"WebPubSubChat.ChatRoomMember","com.azure.messaging.webpubsub.chat.models.ChatUser":"WebPubSubChat.ChatUser","com.azure.messaging.webpubsub.chat.models.ChatUserKind":"WebPubSubChat.ChatUserKind","com.azure.messaging.webpubsub.chat.models.HumanChatUser":"WebPubSubChat.HumanChatUser","com.azure.messaging.webpubsub.chat.models.MessageContent":"WebPubSubChat.MessageContent"},"generatedFiles":["src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceAsyncClient.java","src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceClient.java","src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceClientBuilder.java","src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceVersion.java","src/main/java/com/azure/messaging/webpubsub/chat/implementation/JsonMergePatchHelper.java","src/main/java/com/azure/messaging/webpubsub/chat/implementation/WebPubSubChatServiceClientImpl.java","src/main/java/com/azure/messaging/webpubsub/chat/implementation/models/GenerateClientTokenResponse.java","src/main/java/com/azure/messaging/webpubsub/chat/implementation/models/package-info.java","src/main/java/com/azure/messaging/webpubsub/chat/implementation/package-info.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatConversation.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatMessage.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatPermission.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatRole.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatRoom.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatRoomMember.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatUser.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatUserKind.java","src/main/java/com/azure/messaging/webpubsub/chat/models/HumanChatUser.java","src/main/java/com/azure/messaging/webpubsub/chat/models/MessageContent.java","src/main/java/com/azure/messaging/webpubsub/chat/models/package-info.java","src/main/java/com/azure/messaging/webpubsub/chat/package-info.java","src/main/java/module-info.java"]} \ No newline at end of file +{"flavor":"azure","apiVersions":{"WebPubSubChat":"2026-08-01-preview"},"crossLanguagePackageId":"WebPubSubChat","crossLanguageVersion":"9db8b5aee1c7","crossLanguageDefinitions":{"com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient":"Customizations.WebPubSubChatServiceClient","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceRole":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceRoleWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceRoom":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceRoomMember":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoomMember","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceRoomMemberWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoomMember","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceRoomWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceTopic":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceTopicWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceUser":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceUserWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteMessage":"WebPubSubChat.WebPubSubChatServiceClient.deleteMessage","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteMessageWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteMessage","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteRole":"WebPubSubChat.WebPubSubChatServiceClient.deleteRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteRoleWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteRoom":"WebPubSubChat.WebPubSubChatServiceClient.deleteRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteRoomMember":"WebPubSubChat.WebPubSubChatServiceClient.deleteRoomMember","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteRoomMemberWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteRoomMember","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteRoomWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteTopic":"WebPubSubChat.WebPubSubChatServiceClient.deleteTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteTopicWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteUser":"WebPubSubChat.WebPubSubChatServiceClient.deleteUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteUserWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.generateClientToken":"Customizations.WebPubSubChatServiceClient.generateClientToken","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.generateClientTokenWithResponse":"Customizations.WebPubSubChatServiceClient.generateClientToken","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getConversation":"WebPubSubChat.WebPubSubChatServiceClient.getConversation","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getConversationWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getConversation","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getRole":"WebPubSubChat.WebPubSubChatServiceClient.getRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getRoleWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getRoom":"WebPubSubChat.WebPubSubChatServiceClient.getRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getRoomWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getTopic":"WebPubSubChat.WebPubSubChatServiceClient.getTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getTopicWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getUser":"WebPubSubChat.WebPubSubChatServiceClient.getUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getUserWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.listMessages":"WebPubSubChat.WebPubSubChatServiceClient.listMessages","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.listRoles":"WebPubSubChat.WebPubSubChatServiceClient.listRoles","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.listRoomMembers":"WebPubSubChat.WebPubSubChatServiceClient.listRoomMembers","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.listRooms":"WebPubSubChat.WebPubSubChatServiceClient.listRooms","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.listRoomsForUser":"WebPubSubChat.WebPubSubChatServiceClient.listRoomsForUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.listTopics":"WebPubSubChat.WebPubSubChatServiceClient.listTopics","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.listUsers":"WebPubSubChat.WebPubSubChatServiceClient.listUsers","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.updateMessage":"WebPubSubChat.WebPubSubChatServiceClient.updateMessage","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.updateMessageWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.updateMessage","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.updateTopic":"WebPubSubChat.WebPubSubChatServiceClient.updateTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.updateTopicWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.updateTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient":"Customizations.WebPubSubChatServiceClient","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceRole":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceRoleWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceRoom":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceRoomMember":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoomMember","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceRoomMemberWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoomMember","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceRoomWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceTopic":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceTopicWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceUser":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceUserWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteMessage":"WebPubSubChat.WebPubSubChatServiceClient.deleteMessage","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteMessageWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteMessage","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteRole":"WebPubSubChat.WebPubSubChatServiceClient.deleteRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteRoleWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteRoom":"WebPubSubChat.WebPubSubChatServiceClient.deleteRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteRoomMember":"WebPubSubChat.WebPubSubChatServiceClient.deleteRoomMember","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteRoomMemberWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteRoomMember","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteRoomWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteTopic":"WebPubSubChat.WebPubSubChatServiceClient.deleteTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteTopicWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteUser":"WebPubSubChat.WebPubSubChatServiceClient.deleteUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteUserWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.generateClientToken":"Customizations.WebPubSubChatServiceClient.generateClientToken","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.generateClientTokenWithResponse":"Customizations.WebPubSubChatServiceClient.generateClientToken","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getConversation":"WebPubSubChat.WebPubSubChatServiceClient.getConversation","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getConversationWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getConversation","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getRole":"WebPubSubChat.WebPubSubChatServiceClient.getRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getRoleWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getRoom":"WebPubSubChat.WebPubSubChatServiceClient.getRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getRoomWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getTopic":"WebPubSubChat.WebPubSubChatServiceClient.getTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getTopicWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getUser":"WebPubSubChat.WebPubSubChatServiceClient.getUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getUserWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.listMessages":"WebPubSubChat.WebPubSubChatServiceClient.listMessages","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.listRoles":"WebPubSubChat.WebPubSubChatServiceClient.listRoles","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.listRoomMembers":"WebPubSubChat.WebPubSubChatServiceClient.listRoomMembers","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.listRooms":"WebPubSubChat.WebPubSubChatServiceClient.listRooms","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.listRoomsForUser":"WebPubSubChat.WebPubSubChatServiceClient.listRoomsForUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.listTopics":"WebPubSubChat.WebPubSubChatServiceClient.listTopics","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.listUsers":"WebPubSubChat.WebPubSubChatServiceClient.listUsers","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.updateMessage":"WebPubSubChat.WebPubSubChatServiceClient.updateMessage","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.updateMessageWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.updateMessage","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.updateTopic":"WebPubSubChat.WebPubSubChatServiceClient.updateTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.updateTopicWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.updateTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClientBuilder":"Customizations.WebPubSubChatServiceClient","com.azure.messaging.webpubsub.chat.implementation.models.GenerateClientTokenResponse":"Customizations.GenerateClientTokenResponse","com.azure.messaging.webpubsub.chat.models.ChatConversation":"WebPubSubChat.ChatConversation","com.azure.messaging.webpubsub.chat.models.ChatMessage":"WebPubSubChat.ChatMessage","com.azure.messaging.webpubsub.chat.models.ChatPermission":"WebPubSubChat.ChatPermission","com.azure.messaging.webpubsub.chat.models.ChatRole":"WebPubSubChat.ChatRole","com.azure.messaging.webpubsub.chat.models.ChatRoom":"WebPubSubChat.ChatRoom","com.azure.messaging.webpubsub.chat.models.ChatRoomMember":"WebPubSubChat.ChatRoomMember","com.azure.messaging.webpubsub.chat.models.ChatTopic":"WebPubSubChat.ChatTopic","com.azure.messaging.webpubsub.chat.models.ChatTopicState":"WebPubSubChat.ChatTopicState","com.azure.messaging.webpubsub.chat.models.ChatUser":"WebPubSubChat.ChatUser","com.azure.messaging.webpubsub.chat.models.ChatUserKind":"WebPubSubChat.ChatUserKind","com.azure.messaging.webpubsub.chat.models.ChatUserRoom":"WebPubSubChat.ChatUserRoom","com.azure.messaging.webpubsub.chat.models.HumanChatUser":"WebPubSubChat.HumanChatUser","com.azure.messaging.webpubsub.chat.models.MessageContent":"WebPubSubChat.MessageContent"},"generatedFiles":["src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceAsyncClient.java","src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceClient.java","src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceClientBuilder.java","src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceVersion.java","src/main/java/com/azure/messaging/webpubsub/chat/implementation/JsonMergePatchHelper.java","src/main/java/com/azure/messaging/webpubsub/chat/implementation/WebPubSubChatServiceClientImpl.java","src/main/java/com/azure/messaging/webpubsub/chat/implementation/models/GenerateClientTokenResponse.java","src/main/java/com/azure/messaging/webpubsub/chat/implementation/models/package-info.java","src/main/java/com/azure/messaging/webpubsub/chat/implementation/package-info.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatConversation.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatMessage.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatPermission.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatRole.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatRoom.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatRoomMember.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatTopic.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatTopicState.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatUser.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatUserKind.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatUserRoom.java","src/main/java/com/azure/messaging/webpubsub/chat/models/HumanChatUser.java","src/main/java/com/azure/messaging/webpubsub/chat/models/MessageContent.java","src/main/java/com/azure/messaging/webpubsub/chat/models/package-info.java","src/main/java/com/azure/messaging/webpubsub/chat/package-info.java","src/main/java/module-info.java"]} \ No newline at end of file diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/samples/java/com/azure/messaging/webpubsub/chat/WebPubSubChatSamples.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/samples/java/com/azure/messaging/webpubsub/chat/WebPubSubChatSamples.java index bcb50ea90d325..c0a7cb9160856 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/samples/java/com/azure/messaging/webpubsub/chat/WebPubSubChatSamples.java +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/samples/java/com/azure/messaging/webpubsub/chat/WebPubSubChatSamples.java @@ -4,12 +4,15 @@ package com.azure.messaging.webpubsub.chat; import com.azure.core.credential.AzureKeyCredential; +import com.azure.core.http.rest.RequestOptions; import com.azure.identity.DefaultAzureCredentialBuilder; import com.azure.messaging.webpubsub.chat.models.BuiltInChatRoles; import com.azure.messaging.webpubsub.chat.models.ChatPermission; import com.azure.messaging.webpubsub.chat.models.ChatRole; import com.azure.messaging.webpubsub.chat.models.ChatRoom; import com.azure.messaging.webpubsub.chat.models.ChatRoomMember; +import com.azure.messaging.webpubsub.chat.models.ChatTopic; +import com.azure.messaging.webpubsub.chat.models.ChatTopicState; import com.azure.messaging.webpubsub.chat.models.GetClientAccessTokenOptions; import com.azure.messaging.webpubsub.chat.models.HumanChatUser; import com.azure.messaging.webpubsub.chat.models.WebPubSubClientAccessToken; @@ -62,66 +65,161 @@ public void getClientAccessToken() { // END: readme-sample-getChatClientAccessToken } - /** Creates and lists a custom Chat role. */ - public void manageRoles() { - WebPubSubChatServiceClient client = createClient(); + /** Creates a custom Chat role. */ + public void createRole(WebPubSubChatServiceClient client) { - // BEGIN: readme-sample-manageChatRoles + // BEGIN: readme-sample-createChatRole ChatRole moderator = new ChatRole(Arrays.asList(ChatPermission.ROOM_HISTORY, ChatPermission.ROOM_REMOVE_USER, ChatPermission.ROOM_PUBLISH_MESSAGE)); client.createOrReplaceRole("room.moderator", moderator); + // END: readme-sample-createChatRole + } + /** Lists Chat roles. */ + public void listRoles(WebPubSubChatServiceClient client) { + // BEGIN: readme-sample-listChatRoles client.listRoles().forEach(role -> System.out.println(role.getName())); - client.deleteRole("room.moderator"); - // END: readme-sample-manageChatRoles + // END: readme-sample-listChatRoles } - /** Creates a room and assigns a member. */ - public void manageRooms() { - WebPubSubChatServiceClient client = createClient(); + /** Deletes a custom Chat role. */ + public void deleteRole(WebPubSubChatServiceClient client) { + // BEGIN: readme-sample-deleteChatRole + client.deleteRole("room.moderator"); + // END: readme-sample-deleteChatRole + } - // BEGIN: readme-sample-manageChatRooms - client.createOrReplaceRole("user.room_creator", - new ChatRole(Arrays.asList(ChatPermission.USER_CREATE_ROOM))); - client.createOrReplaceRole("room.contributor", - new ChatRole(Arrays.asList(ChatPermission.ROOM_PUBLISH_MESSAGE))); - client.createOrReplaceUser("alice", new HumanChatUser("Alice", "user.room_creator")); + /** Creates a Chat user with a built-in role. */ + public void createUser(WebPubSubChatServiceClient client) { + // BEGIN: readme-sample-createChatUser + client.createOrReplaceUser("alice", new HumanChatUser("Alice", BuiltInChatRoles.USER_NORMAL)); + // END: readme-sample-createChatUser + } + /** Creates a Chat room. */ + public void createRoom(WebPubSubChatServiceClient client) { + // BEGIN: readme-sample-createChatRoom ChatRoom room = client.createOrReplaceRoom("general", new ChatRoom("General")); + String defaultConversationId = room.getDefaultConversation(); + // END: readme-sample-createChatRoom + } + + /** Adds an existing user to an existing room. */ + public void addRoomMember(WebPubSubChatServiceClient client) { + // BEGIN: readme-sample-addChatRoomMember ChatRoomMember member = client.createOrReplaceRoomMember( - room.getId(), "alice", new ChatRoomMember("room.contributor")); + "general", "alice", new ChatRoomMember(BuiltInChatRoles.ROOM_MEMBER)); System.out.printf("%s: %s%n", member.getUserId(), member.getRoleName()); + // END: readme-sample-addChatRoomMember + } - client.deleteRoom(room.getId()); - client.deleteUser("alice"); - client.deleteRole("room.contributor"); - client.deleteRole("user.room_creator"); - // END: readme-sample-manageChatRooms + /** Lists rooms in a hub. */ + public void listRooms() { + WebPubSubChatServiceClient client = createClient(); + // BEGIN: readme-sample-listChatRooms + client.listRooms().forEach(room -> System.out.printf("%s: %s%n", room.getId(), room.getTitle())); + // END: readme-sample-listChatRooms } - /** Lists persisted messages in a room's default conversation. */ - public void listMessages() { + /** Lists user profiles in a hub. */ + public void listUsers() { + WebPubSubChatServiceClient client = createClient(); + // BEGIN: readme-sample-listChatUsers + client.listUsers().forEach(user -> System.out.printf("%s: %s%n", user.getId(), user.getNickname())); + // END: readme-sample-listChatUsers + } + + /** Lists rooms associated with an existing user. */ + public void listRoomsForUser() { WebPubSubChatServiceClient client = createClient(); + // BEGIN: readme-sample-listChatRoomsForUser + client.listRoomsForUser("alice").forEach(room -> + System.out.printf("%s: %s%n", room.getId(), room.getTitle())); + // END: readme-sample-listChatRoomsForUser + } + + /** Creates a topic in an existing room. */ + public void createTopic() { + WebPubSubChatServiceClient client = createClient(); + // BEGIN: readme-sample-createChatTopic + ChatTopic topic = client.createOrReplaceTopic("general", "announcements", + new ChatTopic().setTitle("Announcements")); + String conversationId = topic.getConversationId(); + // END: readme-sample-createChatTopic + } + /** Gets an existing topic. */ + public void getTopic() { + WebPubSubChatServiceClient client = createClient(); + // BEGIN: readme-sample-getChatTopic + ChatTopic topic = client.getTopic("general", "announcements"); + System.out.printf("%s: %s%n", topic.getTitle(), topic.getState()); + // END: readme-sample-getChatTopic + } + + /** Updates an existing topic's title and lifecycle state. */ + public void updateTopic() { + WebPubSubChatServiceClient client = createClient(); + // BEGIN: readme-sample-updateChatTopic + ChatTopic updated = client.updateTopic("general", "announcements", + new ChatTopic().setTitle("Archived announcements").setState(ChatTopicState.ARCHIVED)); + // END: readme-sample-updateChatTopic + } + + /** Soft deletes an existing topic. */ + public void deleteTopic() { + WebPubSubChatServiceClient client = createClient(); + // BEGIN: readme-sample-deleteChatTopic + client.deleteTopic("general", "announcements"); + // END: readme-sample-deleteChatTopic + } + + /** Lists topics in an existing room. */ + public void listTopics() { + WebPubSubChatServiceClient client = createClient(); + // BEGIN: readme-sample-listChatTopics + client.listTopics("general").forEach(topic -> + System.out.printf("%s: %s%n", topic.getId(), topic.getTitle())); + // END: readme-sample-listChatTopics + } + + /** Lists persisted messages in a room's default conversation. */ + public void listMessages(WebPubSubChatServiceClient client) { // BEGIN: readme-sample-listChatMessages - ChatRoom room = client.getRoom("general"); - client.listMessages(room.getDefaultConversation()).forEach(message -> + String conversationId = ""; + client.listMessages(conversationId).forEach(message -> System.out.printf("%s: %s%n", message.getCreatedBy(), message.getContent().getText())); // END: readme-sample-listChatMessages } - /** Creates an asynchronous client and lists roles. */ + /** Creates an asynchronous client. */ public void createAsyncClient() { // BEGIN: readme-sample-createAsyncChatClient WebPubSubChatServiceAsyncClient asyncClient = new WebPubSubChatServiceClientBuilder() .connectionString("") .hub("chat") .buildAsyncClient(); - - asyncClient.listRoles().subscribe(role -> System.out.println(role.getName())); // END: readme-sample-createAsyncChatClient } + /** Lists topics asynchronously. */ + public void listTopicsAsync(WebPubSubChatServiceAsyncClient asyncClient) { + // BEGIN: readme-sample-listChatTopicsAsync + asyncClient.listTopics("general").subscribe( + topic -> System.out.println(topic.getTitle()), + error -> System.err.println("Could not list topics: " + error.getMessage())); + // END: readme-sample-listChatTopicsAsync + } + + /** Uses protocol paging while the typed async page-size override is awaiting an upstream fix. */ + public void listTopicsAsyncByPage(WebPubSubChatServiceAsyncClient asyncClient) { + // BEGIN: readme-sample-listChatTopicsAsyncByPage + asyncClient.listTopics("general", new RequestOptions()).byPage(10).subscribe( + page -> page.getValue().forEach(data -> System.out.println(data.toObject(ChatTopic.class).getTitle())), + error -> System.err.println("Could not list topic pages: " + error.getMessage())); + // END: readme-sample-listChatTopicsAsyncByPage + } + /** Reads the built-in role and permission values. */ public void builtInValues() { // BEGIN: readme-sample-chatBuiltInValues diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/ChatServiceAugustAsyncClientLiveTests.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/ChatServiceAugustAsyncClientLiveTests.java new file mode 100644 index 0000000000000..1520814e42eb2 --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/ChatServiceAugustAsyncClientLiveTests.java @@ -0,0 +1,181 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.messaging.webpubsub.chat; + +import com.azure.core.exception.HttpResponseException; +import com.azure.core.http.MatchConditions; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.util.BinaryData; +import com.azure.messaging.webpubsub.chat.models.BuiltInChatRoles; +import com.azure.messaging.webpubsub.chat.models.ChatRoom; +import com.azure.messaging.webpubsub.chat.models.ChatRoomMember; +import com.azure.messaging.webpubsub.chat.models.ChatTopic; +import com.azure.messaging.webpubsub.chat.models.ChatTopicState; +import com.azure.messaging.webpubsub.chat.models.ChatUser; +import com.azure.messaging.webpubsub.chat.models.ChatUserRoom; +import com.azure.messaging.webpubsub.chat.models.HumanChatUser; +import org.junit.jupiter.api.Test; + +import java.util.List; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; + +public class ChatServiceAugustAsyncClientLiveTests extends ChatServiceClientTestBase { + @Test + public void canManageTopicsWithConditionsAndPagination() { + String roomId = testResourceNamer.randomName("java-async-topic-room-", 55); + String firstTopicId = "first"; + String secondTopicId = "second"; + + try { + asyncClient.createOrReplaceRoom(roomId, new ChatRoom("Java async topic test room")).block(); + ChatTopic created + = asyncClient + .createOrReplaceTopic(roomId, firstTopicId, new ChatTopic().setTitle("First topic"), + new MatchConditions().setIfNoneMatch("*")) + .block(); + assertEquals(firstTopicId, created.getId()); + assertEquals(ChatTopicState.NORMAL, created.getState()); + assertNotNull(created.getCreatedAt()); + assertNotNull(created.getCreatedBy()); + assertNotNull(created.getConversationId()); + assertNotNull(created.getEtag()); + assertEquals("First topic", entraAsyncClient.getTopic(roomId, firstTopicId).block().getTitle()); + + HttpResponseException duplicate = assertThrows(HttpResponseException.class, + () -> asyncClient + .createOrReplaceTopic(roomId, firstTopicId, new ChatTopic().setTitle("Duplicate"), + new MatchConditions().setIfNoneMatch("*")) + .block()); + assertEquals(412, duplicate.getResponse().getStatusCode()); + ChatTopic replaced + = asyncClient + .createOrReplaceTopic(roomId, firstTopicId, new ChatTopic().setTitle("Replaced topic"), + new MatchConditions().setIfMatch(created.getEtag())) + .block(); + ChatTopic updated + = asyncClient + .updateTopic(roomId, firstTopicId, + new ChatTopic().setTitle("Updated topic").setState(ChatTopicState.ARCHIVED), + new MatchConditions().setIfMatch(replaced.getEtag())) + .block(); + assertEquals("Updated topic", updated.getTitle()); + assertEquals(ChatTopicState.ARCHIVED, updated.getState()); + assertEquals(created.getConversationId(), updated.getConversationId()); + HttpResponseException stale = assertThrows(HttpResponseException.class, + () -> asyncClient + .updateTopic(roomId, firstTopicId, new ChatTopic().setTitle("Stale update"), + new MatchConditions().setIfMatch(replaced.getEtag())) + .block()); + assertEquals(412, stale.getResponse().getStatusCode()); + + asyncClient.createOrReplaceTopic(roomId, secondTopicId, new ChatTopic().setTitle("Second topic")).block(); + // Protocol paging preserves page size until microsoft/typespec#12149 is fixed. + List> pages + = asyncClient.listTopics(roomId, new RequestOptions()).byPage(1).take(2).collectList().block(); + assertEquals(2, pages.size()); + assertEquals(1, pages.get(0).getValue().size()); + assertNotNull(pages.get(0).getContinuationToken()); + assertEquals(1, pages.get(1).getValue().size()); + assertNotEquals(pages.get(0).getValue().get(0).toObject(ChatTopic.class).getId(), + pages.get(1).getValue().get(0).toObject(ChatTopic.class).getId()); + List topicIds = asyncClient.listTopics(roomId).map(ChatTopic::getId).collectList().block(); + assertTrue(topicIds.contains(firstTopicId)); + assertTrue(topicIds.contains(secondTopicId)); + + asyncClient.deleteTopic(roomId, firstTopicId, new MatchConditions().setIfMatch(updated.getEtag())).block(); + asyncClient.deleteTopic(roomId, secondTopicId).block(); + } finally { + cleanup(() -> asyncClient.deleteRoom(roomId).block()); + } + } + + @Test + public void canListRoomsAndUsersWithPagination() { + String suffix = testResourceNamer.randomName("java", 20); + String firstRoomId = "java-async-list-room-a-" + suffix; + String secondRoomId = "java-async-list-room-b-" + suffix; + String firstUserId = "java-async-list-user-a-" + suffix; + String secondUserId = "java-async-list-user-b-" + suffix; + + try { + asyncClient.createOrReplaceRoom(firstRoomId, new ChatRoom("First room")).block(); + asyncClient.createOrReplaceRoom(secondRoomId, new ChatRoom("Second room")).block(); + asyncClient.createOrReplaceUser(firstUserId, new HumanChatUser("First user", BuiltInChatRoles.USER_NORMAL)) + .block(); + asyncClient + .createOrReplaceUser(secondUserId, new HumanChatUser("Second user", BuiltInChatRoles.USER_NORMAL)) + .block(); + + List roomIds = asyncClient.listRooms(new RequestOptions()) + .byPage(1) + .flatMapIterable(PagedResponse::getValue) + .map(data -> data.toObject(ChatRoom.class).getId()) + .collectList() + .block(); + assertTrue(roomIds.contains(firstRoomId)); + assertTrue(roomIds.contains(secondRoomId)); + List users = entraAsyncClient.listUsers(new RequestOptions()) + .byPage(1) + .flatMapIterable(PagedResponse::getValue) + .map(data -> data.toObject(ChatUser.class)) + .collectList() + .block(); + assertTrue( + users.stream().anyMatch(user -> firstUserId.equals(user.getId()) && user instanceof HumanChatUser)); + assertTrue(users.stream().anyMatch(user -> secondUserId.equals(user.getId()))); + } finally { + cleanup(() -> asyncClient.deleteRoom(firstRoomId).block()); + cleanup(() -> asyncClient.deleteRoom(secondRoomId).block()); + cleanup(() -> asyncClient.deleteUser(firstUserId).block()); + cleanup(() -> asyncClient.deleteUser(secondUserId).block()); + } + } + + @Test + public void canListRoomsForUserWithPagination() { + String suffix = testResourceNamer.randomName("java", 20); + String userId = "java-async-user-rooms-" + suffix; + String firstRoomId = "java-async-user-room-a-" + suffix; + String secondRoomId = "java-async-user-room-b-" + suffix; + + try { + asyncClient.createOrReplaceUser(userId, new HumanChatUser("Room list user", BuiltInChatRoles.USER_NORMAL)) + .block(); + asyncClient.createOrReplaceRoom(firstRoomId, new ChatRoom("First user room")).block(); + asyncClient.createOrReplaceRoom(secondRoomId, new ChatRoom("Second user room")).block(); + assertEquals(0, asyncClient.listRoomsForUser(userId).count().block()); + asyncClient.createOrReplaceRoomMember(firstRoomId, userId, new ChatRoomMember(BuiltInChatRoles.ROOM_MEMBER)) + .block(); + asyncClient + .createOrReplaceRoomMember(secondRoomId, userId, new ChatRoomMember(BuiltInChatRoles.ROOM_MEMBER)) + .block(); + + List> pages + = asyncClient.listRoomsForUser(userId, new RequestOptions()).byPage(1).collectList().block(); + assertEquals(2, pages.size()); + assertEquals(1, pages.get(0).getValue().size()); + assertNotNull(pages.get(0).getContinuationToken()); + assertEquals(1, pages.get(1).getValue().size()); + assertNotEquals(pages.get(0).getValue().get(0).toObject(ChatUserRoom.class).getId(), + pages.get(1).getValue().get(0).toObject(ChatUserRoom.class).getId()); + List rooms = asyncClient.listRoomsForUser(userId).collectList().block(); + assertEquals(2, rooms.size()); + assertTrue(rooms.stream() + .anyMatch(room -> firstRoomId.equals(room.getId()) + && "First user room".equals(room.getTitle()) + && room.getDefaultConversation() != null)); + assertTrue(rooms.stream().anyMatch(room -> secondRoomId.equals(room.getId()))); + } finally { + cleanup(() -> asyncClient.deleteRoom(firstRoomId).block()); + cleanup(() -> asyncClient.deleteRoom(secondRoomId).block()); + cleanup(() -> asyncClient.deleteUser(userId).block()); + } + } +} diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/ChatServiceAugustClientLiveTests.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/ChatServiceAugustClientLiveTests.java new file mode 100644 index 0000000000000..2a6d91ca3b5a8 --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/ChatServiceAugustClientLiveTests.java @@ -0,0 +1,156 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.messaging.webpubsub.chat; + +import com.azure.core.exception.HttpResponseException; +import com.azure.core.http.MatchConditions; +import com.azure.core.http.rest.PagedResponse; +import com.azure.messaging.webpubsub.chat.models.BuiltInChatRoles; +import com.azure.messaging.webpubsub.chat.models.ChatRoom; +import com.azure.messaging.webpubsub.chat.models.ChatRoomMember; +import com.azure.messaging.webpubsub.chat.models.ChatTopic; +import com.azure.messaging.webpubsub.chat.models.ChatTopicState; +import com.azure.messaging.webpubsub.chat.models.ChatUser; +import com.azure.messaging.webpubsub.chat.models.ChatUserRoom; +import com.azure.messaging.webpubsub.chat.models.HumanChatUser; +import org.junit.jupiter.api.Test; + +import java.util.Iterator; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.StreamSupport; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; + +public class ChatServiceAugustClientLiveTests extends ChatServiceClientTestBase { + @Test + public void canManageTopicsWithConditionsAndPagination() { + String roomId = testResourceNamer.randomName("java-topic-room-", 50); + String firstTopicId = "first"; + String secondTopicId = "second"; + + try { + client.createOrReplaceRoom(roomId, new ChatRoom("Java topic test room")); + ChatTopic created = client.createOrReplaceTopic(roomId, firstTopicId, + new ChatTopic().setTitle("First topic"), new MatchConditions().setIfNoneMatch("*")); + assertEquals(firstTopicId, created.getId()); + assertEquals(ChatTopicState.NORMAL, created.getState()); + assertNotNull(created.getCreatedAt()); + assertNotNull(created.getCreatedBy()); + assertNotNull(created.getConversationId()); + assertNotNull(created.getEtag()); + assertEquals("First topic", entraClient.getTopic(roomId, firstTopicId).getTitle()); + + HttpResponseException duplicate + = assertThrows(HttpResponseException.class, () -> client.createOrReplaceTopic(roomId, firstTopicId, + new ChatTopic().setTitle("Duplicate"), new MatchConditions().setIfNoneMatch("*"))); + assertEquals(412, duplicate.getResponse().getStatusCode()); + + ChatTopic replaced = client.createOrReplaceTopic(roomId, firstTopicId, + new ChatTopic().setTitle("Replaced topic"), new MatchConditions().setIfMatch(created.getEtag())); + ChatTopic updated = client.updateTopic(roomId, firstTopicId, + new ChatTopic().setTitle("Updated topic").setState(ChatTopicState.ARCHIVED), + new MatchConditions().setIfMatch(replaced.getEtag())); + assertEquals("Updated topic", updated.getTitle()); + assertEquals(ChatTopicState.ARCHIVED, updated.getState()); + assertEquals(created.getConversationId(), updated.getConversationId()); + HttpResponseException stale + = assertThrows(HttpResponseException.class, () -> client.updateTopic(roomId, firstTopicId, + new ChatTopic().setTitle("Stale update"), new MatchConditions().setIfMatch(replaced.getEtag()))); + assertEquals(412, stale.getResponse().getStatusCode()); + + client.createOrReplaceTopic(roomId, secondTopicId, new ChatTopic().setTitle("Second topic")); + Iterator> pages = client.listTopics(roomId).iterableByPage(1).iterator(); + PagedResponse firstPage = pages.next(); + assertEquals(1, firstPage.getValue().size()); + assertNotNull(firstPage.getContinuationToken()); + PagedResponse secondPage = pages.next(); + assertEquals(1, secondPage.getValue().size()); + assertNotEquals(firstPage.getValue().get(0).getId(), secondPage.getValue().get(0).getId()); + List topicIds + = client.listTopics(roomId).stream().map(ChatTopic::getId).collect(Collectors.toList()); + assertTrue(topicIds.contains(firstTopicId)); + assertTrue(topicIds.contains(secondTopicId)); + + client.deleteTopic(roomId, firstTopicId, new MatchConditions().setIfMatch(updated.getEtag())); + client.deleteTopic(roomId, secondTopicId); + } finally { + cleanup(() -> client.deleteRoom(roomId)); + } + } + + @Test + public void canListRoomsAndUsersWithPagination() { + String suffix = testResourceNamer.randomName("java", 20); + String firstRoomId = "java-list-room-a-" + suffix; + String secondRoomId = "java-list-room-b-" + suffix; + String firstUserId = "java-list-user-a-" + suffix; + String secondUserId = "java-list-user-b-" + suffix; + + try { + client.createOrReplaceRoom(firstRoomId, new ChatRoom("First room")); + client.createOrReplaceRoom(secondRoomId, new ChatRoom("Second room")); + client.createOrReplaceUser(firstUserId, new HumanChatUser("First user", BuiltInChatRoles.USER_NORMAL)); + client.createOrReplaceUser(secondUserId, new HumanChatUser("Second user", BuiltInChatRoles.USER_NORMAL)); + + List roomIds = StreamSupport.stream(client.listRooms().iterableByPage(1).spliterator(), false) + .flatMap(page -> page.getValue().stream()) + .map(ChatRoom::getId) + .collect(Collectors.toList()); + assertTrue(roomIds.contains(firstRoomId)); + assertTrue(roomIds.contains(secondRoomId)); + List users = StreamSupport.stream(entraClient.listUsers().iterableByPage(1).spliterator(), false) + .flatMap(page -> page.getValue().stream()) + .collect(Collectors.toList()); + assertTrue( + users.stream().anyMatch(user -> firstUserId.equals(user.getId()) && user instanceof HumanChatUser)); + assertTrue(users.stream().anyMatch(user -> secondUserId.equals(user.getId()))); + } finally { + cleanup(() -> client.deleteRoom(firstRoomId)); + cleanup(() -> client.deleteRoom(secondRoomId)); + cleanup(() -> client.deleteUser(firstUserId)); + cleanup(() -> client.deleteUser(secondUserId)); + } + } + + @Test + public void canListRoomsForUserWithPagination() { + String suffix = testResourceNamer.randomName("java", 20); + String userId = "java-user-rooms-" + suffix; + String firstRoomId = "java-user-room-a-" + suffix; + String secondRoomId = "java-user-room-b-" + suffix; + + try { + client.createOrReplaceUser(userId, new HumanChatUser("Room list user", BuiltInChatRoles.USER_NORMAL)); + client.createOrReplaceRoom(firstRoomId, new ChatRoom("First user room")); + client.createOrReplaceRoom(secondRoomId, new ChatRoom("Second user room")); + assertEquals(0, client.listRoomsForUser(userId).stream().count()); + client.createOrReplaceRoomMember(firstRoomId, userId, new ChatRoomMember(BuiltInChatRoles.ROOM_MEMBER)); + client.createOrReplaceRoomMember(secondRoomId, userId, new ChatRoomMember(BuiltInChatRoles.ROOM_MEMBER)); + + Iterator> pages = client.listRoomsForUser(userId).iterableByPage(1).iterator(); + PagedResponse firstPage = pages.next(); + assertEquals(1, firstPage.getValue().size()); + assertNotNull(firstPage.getContinuationToken()); + PagedResponse secondPage = pages.next(); + assertEquals(1, secondPage.getValue().size()); + assertNotEquals(firstPage.getValue().get(0).getId(), secondPage.getValue().get(0).getId()); + List rooms = client.listRoomsForUser(userId).stream().collect(Collectors.toList()); + assertEquals(2, rooms.size()); + assertTrue(rooms.stream() + .anyMatch(room -> firstRoomId.equals(room.getId()) + && "First user room".equals(room.getTitle()) + && room.getDefaultConversation() != null)); + assertTrue(rooms.stream().anyMatch(room -> secondRoomId.equals(room.getId()))); + } finally { + cleanup(() -> client.deleteRoom(firstRoomId)); + cleanup(() -> client.deleteRoom(secondRoomId)); + cleanup(() -> client.deleteUser(userId)); + } + } +} diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/ChatServiceClientTestBase.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/ChatServiceClientTestBase.java index ab8ddc7a6ff08..a3e473abbecef 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/ChatServiceClientTestBase.java +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/ChatServiceClientTestBase.java @@ -6,15 +6,19 @@ import com.azure.core.http.HttpClient; import com.azure.core.test.TestMode; import com.azure.core.test.TestProxyTestBase; +import com.azure.core.test.models.CustomMatcher; import com.azure.core.test.models.TestProxySanitizer; import com.azure.core.test.models.TestProxySanitizerType; import com.azure.core.test.utils.MockTokenCredential; import com.azure.core.util.Configuration; +import com.azure.core.util.logging.ClientLogger; import com.azure.identity.DefaultAzureCredentialBuilder; +import java.util.Arrays; import java.util.Collections; abstract class ChatServiceClientTestBase extends TestProxyTestBase { + private static final ClientLogger LOGGER = new ClientLogger(ChatServiceClientTestBase.class); private static final String CONNECTION_STRING = Configuration.getGlobalConfiguration() .get("WPS_CHAT_CONNECTION_STRING", "Endpoint=https://testendpoint.webpubsubdev.azure.com;AccessKey=LoremIpsumDolorSitAmetConsectetur;Version=1.0;"); @@ -36,6 +40,12 @@ protected void beforeTest() { Collections.singletonList(new TestProxySanitizer("https://(?[^/]+[.]webpubsub[.]azure[.]com)", "REDACTED", TestProxySanitizerType.BODY_REGEX).setGroupForReplace("host"))); } + if (getTestMode() == TestMode.PLAYBACK) { + // Standard sanitizers remove these volatile headers from recordings. + interceptorManager.addMatchers( + new CustomMatcher().setExcludedHeaders(Arrays.asList("Authorization", "x-ms-client-request-id")) + .setComparingBodies(true)); + } HttpClient httpClient = getHttpClientOrUsePlayback(getHttpClients().findFirst().orElse(HttpClient.createDefault())); @@ -67,8 +77,8 @@ protected void beforeTest() { protected static void cleanup(Runnable cleanup) { try { cleanup.run(); - } catch (RuntimeException ignored) { - // Preserve the original test failure while making a best effort to remove live resources. + } catch (RuntimeException exception) { + LOGGER.warning("Failed to clean up live test resources.", exception); } } } diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/WebPubSubChatPaginationTests.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/WebPubSubChatPaginationTests.java new file mode 100644 index 0000000000000..a8fed7894535e --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/WebPubSubChatPaginationTests.java @@ -0,0 +1,163 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.messaging.webpubsub.chat; + +import com.azure.core.http.HttpClient; +import com.azure.core.http.HttpHeaderName; +import com.azure.core.http.HttpHeaders; +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.test.http.MockHttpResponse; +import com.azure.core.test.utils.MockTokenCredential; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; +import reactor.core.publisher.Mono; + +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.List; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +public class WebPubSubChatPaginationTests { + @ParameterizedTest + @ValueSource(strings = { "roles", "members", "messages", "rooms", "topics", "users", "userRooms" }) + public void syncPageSizeReachesFirstAndNextRequests(String operation) { + List requests = new ArrayList<>(); + WebPubSubChatServiceClient client = builder(requests).buildClient(); + + syncPages(client, operation).iterableByPage(1).forEach(page -> { + }); + + assertPageSize(requests); + } + + @Disabled("Awaiting upstream Java generator fix: https://github.com/microsoft/typespec/issues/12149") + @ParameterizedTest + @ValueSource(strings = { "roles", "members", "messages", "rooms", "topics", "users", "userRooms" }) + public void asyncPageSizeReachesFirstAndNextRequests(String operation) { + List requests = new ArrayList<>(); + WebPubSubChatServiceAsyncClient client = builder(requests).buildAsyncClient(); + + assertEquals(2, asyncPages(client, operation, false).byPage(1).collectList().block().size()); + + assertPageSize(requests); + } + + @ParameterizedTest + @ValueSource(strings = { "roles", "members", "messages", "rooms", "topics", "users", "userRooms" }) + public void asyncProtocolPageSizeReachesFirstAndNextRequests(String operation) { + List requests = new ArrayList<>(); + WebPubSubChatServiceAsyncClient client = builder(requests).buildAsyncClient(); + + assertEquals(2, asyncPages(client, operation, true).byPage(1).collectList().block().size()); + + assertPageSize(requests); + } + + @ParameterizedTest + @ValueSource(booleans = { false, true }) + public void roomsForUserContinuationIsAQueryParameter(boolean async) { + List requests = new ArrayList<>(); + WebPubSubChatServiceClientBuilder builder = builder(requests); + if (async) { + builder.buildAsyncClient().listRoomsForUser("alice", "initial-token").byPage().collectList().block(); + } else { + builder.buildClient().listRoomsForUser("alice", "initial-token").iterableByPage().forEach(page -> { + }); + } + assertTrue(requests.get(0).contains("continuationToken=initial-token")); + } + + private static void assertPageSize(List requests) { + assertEquals(2, requests.size()); + for (String request : requests) { + assertTrue(request.contains("maxpagesize=1"), request); + } + assertTrue(requests.get(1).contains("continuationToken=next")); + } + + private static WebPubSubChatServiceClientBuilder builder(List requests) { + HttpClient transport = request -> Mono.defer(() -> { + String url = request.getUrl().toString(); + requests.add(url); + String body = "{\"value\":[]}"; + if (requests.size() == 1) { + String nextLink = "https://example.webpubsub.azure.com" + request.getUrl().getPath() + + "?api-version=2026-08-01-preview&continuationToken=next"; + body = "{\"value\":[],\"nextLink\":\"" + nextLink + "\"}"; + } + return Mono.just(new MockHttpResponse(request, 200, + new HttpHeaders().set(HttpHeaderName.CONTENT_TYPE, "application/json"), + body.getBytes(StandardCharsets.UTF_8))); + }); + return new WebPubSubChatServiceClientBuilder().endpoint("https://example.webpubsub.azure.com") + .hub("chat") + .credential(new MockTokenCredential()) + .httpClient(transport); + } + + private static PagedIterable syncPages(WebPubSubChatServiceClient client, String operation) { + switch (operation) { + case "roles": + return client.listRoles(); + + case "members": + return client.listRoomMembers("room"); + + case "messages": + return client.listMessages("c.room.default"); + + case "rooms": + return client.listRooms(); + + case "topics": + return client.listTopics("room"); + + case "users": + return client.listUsers(); + + case "userRooms": + return client.listRoomsForUser("alice"); + + default: + throw new IllegalArgumentException("Unknown operation: " + operation); + } + } + + private static PagedFlux asyncPages(WebPubSubChatServiceAsyncClient client, String operation, boolean protocol) { + switch (operation) { + case "roles": + return protocol ? client.listRoles(new RequestOptions()) : client.listRoles(); + + case "members": + return protocol ? client.listRoomMembers("room", new RequestOptions()) : client.listRoomMembers("room"); + + case "messages": + return protocol + ? client.listMessages("c.room.default", new RequestOptions()) + : client.listMessages("c.room.default"); + + case "rooms": + return protocol ? client.listRooms(new RequestOptions()) : client.listRooms(); + + case "topics": + return protocol ? client.listTopics("room", new RequestOptions()) : client.listTopics("room"); + + case "users": + return protocol ? client.listUsers(new RequestOptions()) : client.listUsers(); + + case "userRooms": + return protocol + ? client.listRoomsForUser("alice", new RequestOptions()) + : client.listRoomsForUser("alice"); + + default: + throw new IllegalArgumentException("Unknown operation: " + operation); + } + } +} diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceClientBuilderTests.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceClientBuilderTests.java index 77eca61933e15..5eeadb879500d 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceClientBuilderTests.java +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceClientBuilderTests.java @@ -12,6 +12,8 @@ import com.nimbusds.jwt.JWTClaimsSet; import com.nimbusds.jwt.SignedJWT; import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.EnumSource; import reactor.core.publisher.Mono; import java.text.ParseException; @@ -121,11 +123,25 @@ public void connectionStringRejectsMissingRequiredKeys() { } @Test - public void reverseProxyPreservesJavaServiceBehavior() throws ParseException { + public void defaultServiceVersionIsAugustPreview() { + AtomicReference sentRequest = new AtomicReference<>(); + WebPubSubChatServiceClient client = createClient(new AzureKeyCredential(FIRST_KEY), sentRequest); + + assertThrows(ResourceNotFoundException.class, () -> client.getRole("room.reader")); + + assertEquals("api-version=2026-08-01-preview", sentRequest.get().getUrl().getQuery()); + assertEquals(WebPubSubChatServiceVersion.V2026_08_01_PREVIEW, WebPubSubChatServiceVersion.getLatest()); + } + + @ParameterizedTest + @EnumSource(WebPubSubChatServiceVersion.class) + public void reverseProxyPreservesJavaServiceBehavior(WebPubSubChatServiceVersion serviceVersion) + throws ParseException { AtomicReference sentRequest = new AtomicReference<>(); WebPubSubChatServiceClient client = new WebPubSubChatServiceClientBuilder().endpoint(ENDPOINT) .hub("chat") .credential(new AzureKeyCredential(FIRST_KEY)) + .serviceVersion(serviceVersion) .reverseProxyEndpoint("https://proxy.example/gateway") .httpClient(request -> Mono.defer(() -> { sentRequest.set(request); @@ -137,10 +153,10 @@ public void reverseProxyPreservesJavaServiceBehavior() throws ParseException { assertEquals("proxy.example", sentRequest.get().getUrl().getHost()); assertTrue(sentRequest.get().getUrl().getPath().startsWith("/gateway/api/hubs/chat/chat/roles/")); - assertEquals("api-version=2026-02-01-preview", sentRequest.get().getUrl().getQuery()); + assertEquals("api-version=" + serviceVersion.getVersion(), sentRequest.get().getUrl().getQuery()); String authorization = sentRequest.get().getHeaders().getValue(HttpHeaderName.AUTHORIZATION); JWTClaimsSet claims = SignedJWT.parse(authorization.substring("Bearer ".length())).getJWTClaimsSet(); - assertEquals(ENDPOINT + "/api/hubs/chat/chat/roles/room.reader?api-version=2026-02-01-preview", + assertEquals(ENDPOINT + "/api/hubs/chat/chat/roles/room.reader?api-version=" + serviceVersion.getVersion(), claims.getAudience().get(0)); } diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/test-resources.bicep b/sdk/webpubsub/azure-messaging-webpubsub-chat/test-resources.bicep index 28932f949d412..e720664b70705 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/test-resources.bicep +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/test-resources.bicep @@ -4,6 +4,10 @@ param baseName string = resourceGroup().name @description('This is the object id of the service principal used to run tests.') param testApplicationOid string +@description('Principal type of the identity used to run tests.') +@allowed([ 'ServicePrincipal', 'User' ]) +param testPrincipalType string = 'ServicePrincipal' + @description('Location of the resource.') param location string = resourceGroup().location @@ -123,7 +127,7 @@ resource webPubSubOwnerRoleAssignment 'Microsoft.Authorization/roleAssignments@2 properties: { roleDefinitionId: webPubSubOwnerRoleId principalId: testApplicationOid - principalType: 'ServicePrincipal' + principalType: testPrincipalType } } @@ -133,7 +137,7 @@ resource webPubSubOperatorRoleAssignment 'Microsoft.Authorization/roleAssignment properties: { roleDefinitionId: webPubSubOperatorRoleId principalId: testApplicationOid - principalType: 'ServicePrincipal' + principalType: testPrincipalType } } diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/tsp-location.yaml b/sdk/webpubsub/azure-messaging-webpubsub-chat/tsp-location.yaml index c1c137f69eb47..65a6151ea5d53 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/tsp-location.yaml +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/tsp-location.yaml @@ -1,4 +1,4 @@ directory: specification/webpubsub/data-plane/WebPubSubChat -commit: 2f561e5f227705bf7985424de42fc5edd67d3dd7 +commit: 44c2a4f48a4a2e4d77f9658749f990bcf9ab110f repo: Azure/azure-rest-api-specs additionalDirectories: diff --git a/sdk/webpubsub/tests.yml b/sdk/webpubsub/tests.yml index 75019e939c93e..3a0bccad48035 100644 --- a/sdk/webpubsub/tests.yml +++ b/sdk/webpubsub/tests.yml @@ -4,6 +4,9 @@ extends: template: /eng/pipelines/templates/stages/archetype-sdk-tests.yml parameters: ServiceDirectory: webpubsub + TestResourceDirectories: + - webpubsub + - webpubsub/azure-messaging-webpubsub-chat Artifacts: - name: azure-messaging-webpubsub groupId: com.azure @@ -11,6 +14,9 @@ extends: - name: azure-messaging-webpubsub-client groupId: com.azure safeName: azuremessagingwebpubsubclient + - name: azure-messaging-webpubsub-chat + groupId: com.azure + safeName: azuremessagingwebpubsubchat TimeoutInMinutes: 60 EnvVars: AZURE_LOG_LEVEL: 2 From 1a7218b44dc6374b592b42a8e0498bc84683448b Mon Sep 17 00:00:00 2001 From: Zitong Yang Date: Wed, 14 Oct 2026 18:25:28 -0700 Subject: [PATCH 02/18] Fix Web PubSub Chat README links Use an absolute GitHub reference for generator issue tracking and link the available Chat REST API specification instead of an unpublished documentation page. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- sdk/webpubsub/azure-messaging-webpubsub-chat/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/README.md b/sdk/webpubsub/azure-messaging-webpubsub-chat/README.md index 5201a93d40e15..b6a499076254c 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/README.md +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/README.md @@ -307,7 +307,7 @@ asyncClient.listTopics("general", new RequestOptions()).byPage(10).subscribe( error -> System.err.println("Could not list topic pages: " + error.getMessage())); ``` -See [known generator issues](KNOWN_ISSUES.md) for verification and removal of the +See [known generator issues](https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/webpubsub/azure-messaging-webpubsub-chat/KNOWN_ISSUES.md) for verification and removal of the temporary test workaround. No paging customization is applied. ### Service API versions @@ -351,7 +351,7 @@ Explore the [complete package samples][samples] to learn how to: - [Azure Web PubSub documentation][webpubsub_documentation] - [Web PubSub Chat documentation][product_documentation] -- [Web PubSub Chat REST API][rest_api] +- [Web PubSub Chat REST API specification][rest_api] - [Azure SDK for Java design guidelines][design_guidelines] ## Contributing @@ -377,7 +377,7 @@ This project has adopted the [Microsoft Open Source Code of Conduct][code_of_con [azure_identity_auth]: https://learn.microsoft.com/azure/developer/java/sdk/authentication/overview [entra_authorization]: https://learn.microsoft.com/azure/azure-web-pubsub/concept-azure-ad-authorization [logging]: https://learn.microsoft.com/azure/developer/java/sdk/logging-overview -[rest_api]: https://learn.microsoft.com/rest/api/webpubsub/dataplane/webpubsubchat/web-pub-sub-chat-service +[rest_api]: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/webpubsub/data-plane/WebPubSubChat [design_guidelines]: https://azure.github.io/azure-sdk/java_introduction.html [contributing]: https://github.com/Azure/azure-sdk-for-java/blob/main/CONTRIBUTING.md [code_of_conduct]: https://opensource.microsoft.com/codeofconduct/ From b0c86c0b736f8d28b4693f473d5b04bf16fbcbbe Mon Sep 17 00:00:00 2001 From: Zitong Yang Date: Wed, 14 Oct 2026 18:42:10 -0700 Subject: [PATCH 03/18] Verify typed async paging with the upstream Java emitter fix Regenerate Chat with the emitter 0.48.1 already adopted on main. Enable strict paging regressions, use typed async paging in scenarios and samples, and retire the temporary workaround documentation. Fresh-cache playback passes all 59 tests without skips. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../azure-messaging-webpubsub-chat/AGENTS.md | 7 +- .../CHANGELOG.md | 4 +- .../KNOWN_ISSUES.md | 103 +++++------------ .../azure-messaging-webpubsub-chat/README.md | 15 +-- .../chat/WebPubSubChatServiceAsyncClient.java | 104 ++++++++++++++---- .../webpubsub/chat/WebPubSubChatSamples.java | 7 +- ...ChatServiceAugustAsyncClientLiveTests.java | 29 ++--- .../chat/WebPubSubChatPaginationTests.java | 2 - 8 files changed, 132 insertions(+), 139 deletions(-) diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/AGENTS.md b/sdk/webpubsub/azure-messaging-webpubsub-chat/AGENTS.md index da4bc5d0c5f6f..40410731e3229 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/AGENTS.md +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/AGENTS.md @@ -1,9 +1,10 @@ # Web PubSub Chat development constraints Before changing tests, recording tests, regenerating, or releasing this package, -read [KNOWN_ISSUES.md](KNOWN_ISSUES.md) for the pending upstream Java -generator paging fix. Do not add a paging customization; preserve strict -regression assertions and verify the upstream fix after regeneration. +read [KNOWN_ISSUES.md](KNOWN_ISSUES.md) for resolved generator defects and their +regression coverage. Preserve the enabled typed async paging tests and strict +first-page/continuation assertions after regeneration. Do not restore the +removed protocol paging workaround or add a paging customization. Run live tests against a Chat-enabled resource in the TTL = 7 days subscription. The server routing fix was verified in Central US EUAP on 2026-10-13 using the diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/CHANGELOG.md b/sdk/webpubsub/azure-messaging-webpubsub-chat/CHANGELOG.md index f45fc165207ec..24977e72997b0 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/CHANGELOG.md +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/CHANGELOG.md @@ -13,10 +13,12 @@ ### Bugs Fixed +- Regenerated with Java emitter 0.48.1 to preserve page-size overrides on typed asynchronous collections, including continuation requests. + ### Other Changes - Verified all existing and new operations end to end with `2026-08-01-preview` in Central US EUAP; removed the temporary server routing workaround and restored the complete live/playback suite. -- Tracked the upstream typed asynchronous page-size defect in [microsoft/typespec#12149](https://github.com/microsoft/typespec/issues/12149). No paging customization is applied; tests temporarily use protocol overloads for asynchronous page-size checks. +- Enabled all typed asynchronous page-size regression cases and removed the temporary protocol paging workaround from tests and samples. ## 1.0.0-beta.1 (2026-09-15) diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/KNOWN_ISSUES.md b/sdk/webpubsub/azure-messaging-webpubsub-chat/KNOWN_ISSUES.md index 1542134077217..e476096f42c3a 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/KNOWN_ISSUES.md +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/KNOWN_ISSUES.md @@ -1,78 +1,31 @@ -# Web PubSub Chat SDK known generator issues +# Web PubSub Chat generator regression coverage -## Typed asynchronous paging ignores the requested page size +## Resolved: typed asynchronous page-size overrides - **Tracking issue:** [microsoft/typespec#12149](https://github.com/microsoft/typespec/issues/12149). -- **Status:** Awaiting an upstream Java generator fix; reproduced with - `@azure-tools/typespec-java` 0.48.0 on 2026-10-09. -- **User decision:** Do not add a paging customization or manually repair - generated SDK code. Wait for the generator team to fix the implementation. - -The typed asynchronous paged convenience methods accept `pageSizeParam` but -discard it when delegating to `PagedFlux`. For example, -`asyncClient.listRoomsForUser("alice").byPage(1)` does not send `maxpagesize=1`. -Default continuation-token paging still works; the page-size override is -ignored. Synchronous typed paging forwards the page size correctly. - -This affects both existing operations (`listRoles`, `listRoomMembers`, -`listMessages`) and the new operations (`listRooms`, `listTopics`, `listUsers`, -`listRoomsForUser`). The defect predates this package's August API upgrade; the -first affected generator release has not been determined. - -### Approved temporary test workaround - -The user approved disabling only -`WebPubSubChatPaginationTests.asyncPageSizeReachesFirstAndNextRequests`; its -seven strict cases and assertions remain intact. New async live pagination tests -use the existing protocol overloads, such as -`asyncClient.listTopics(roomId, new RequestOptions()).byPage(1)`, and still assert -one item per page and follow continuation requests. Default typed async -collection/model coverage remains enabled. No production paging customization -or generated-code repair is applied. - -The mock suite also verifies first and next request page sizes for all seven -protocol async list methods. Passing these tests does not mean the typed async -generator defect is fixed. - -The implementation belongs to the shared -[Java generator in microsoft/typespec](https://github.com/microsoft/typespec/blob/main/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/ConvenienceAsyncMethodTemplate.java). -The original [Azure/typespec-azure#5657](https://github.com/Azure/typespec-azure/issues/5657) -was filed in the wrong repository and is closed. - -### Checking whether it has been fixed - -1. Check the tracking issue and the version of `@azure-tools/typespec-java` in - `eng/emitter-package.json`. An issue being closed does not prove that the - installed emitter includes the fix. -2. After the repository adopts a generator release containing the fix, - regenerate the package using its pinned `tsp-location.yaml`. Do not bypass - the issue by adding a customization. -3. Remove the issue-linked `@Disabled` annotation from - `asyncPageSizeReachesFirstAndNextRequests`, then run the strict, - credential-free regression tests: - - ```powershell - mvn -f sdk\webpubsub\azure-messaging-webpubsub-chat\pom.xml test "-Dtest=WebPubSubChatPaginationTests" "-Dgpg.skip=true" "-Drevapi.skip=true" - ``` - - `WebPubSubChatPaginationTests` covers all seven sync and async list operations. - It asserts `maxpagesize=1` on **both first-page and continuation requests**, - and checks that the corrected `listRoomsForUser` continuation overload sends - a query parameter. The original 16-case reproduction produced seven async - failures and nine passes. The protocol async cases were added for the - approved test workaround. Do not weaken the assertions or accept skipped async - page-size cases as evidence of a fix. -4. Verify the new sync/async live pagination scenarios, then verify sanitized - recording playback using the persisted `assets.json` tag. Check actual page - sizes and continuation requests, not only whether a non-empty page exists. -5. Only mark this issue resolved after the generated code and all strict - regression cases pass. Switch async live page-size checks back to the typed - overloads and remove the temporary test workaround at that point. - -### Server routing fix is independent - -The server routing issue was verified fixed in Central US EUAP on 2026-10-13: -all 14 sync/async live scenarios passed with `2026-08-01-preview`, including -existing operations and setup/cleanup. The routing workaround and its temporary -skill have been removed. This does not fix the typed async paging generator -defect; retain its strict regression cases and the protocol paging workaround. +- **Upstream fix:** [microsoft/typespec#12163](https://github.com/microsoft/typespec/pull/12163). +- **Verified emitter:** `@azure-tools/typespec-java` 0.48.1, adopted by the shared + repository configuration through [Azure/azure-sdk-for-java#50789](https://github.com/Azure/azure-sdk-for-java/pull/50789). +- **Verification:** Regenerated from the pinned `tsp-location.yaml` on + 2026-10-14. All 59 tests passed with no skips using an independently restored + recording cache, including all seven typed async page-size regression cases. + +The previous generator discarded `pageSizeParam` when converting protocol +`PagedFlux` responses to typed responses. The corrected generator +forwards page size on both first-page and continuation requests while preserving +default paging. No paging customization or manual generated-code fix is used. + +Keep `WebPubSubChatPaginationTests` enabled after future regeneration. Its +23 cases cover all seven sync, typed async, and protocol async list operations, +plus the sync/async `listRoomsForUser` continuation overload. The strict cases +assert `maxpagesize=1` on both requests and check the continuation token. + +The async live scenarios and samples now use typed paging directly. Their +request shapes remain compatible with the sanitized August API recordings; +do not weaken assertions or rewrite recordings to hide a paging regression. + +## Resolved: server routing + +All 14 sync/async live scenarios passed in Central US EUAP on 2026-10-13 with +`2026-08-01-preview`, including existing operations and setup/cleanup. The +legacy-version workaround, routing skips, and temporary skill were removed. diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/README.md b/sdk/webpubsub/azure-messaging-webpubsub-chat/README.md index b6a499076254c..33728cbb3d2d0 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/README.md +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/README.md @@ -293,23 +293,16 @@ asyncClient.listTopics("general").subscribe( error -> System.err.println("Could not list topics: " + error.getMessage())); ``` -#### Known asynchronous page-size limitation +#### Asynchronous paging -The generator currently ignores `byPage(pageSize)` on typed asynchronous -collections. Default continuation paging is unaffected. Until -[microsoft/typespec#12149](https://github.com/microsoft/typespec/issues/12149) -is fixed in the emitter used by this package, use the existing protocol overload -when an explicit asynchronous page size is required: +Use `byPage(pageSize)` on typed asynchronous collections to request a page size: ```java readme-sample-listChatTopicsAsyncByPage -asyncClient.listTopics("general", new RequestOptions()).byPage(10).subscribe( - page -> page.getValue().forEach(data -> System.out.println(data.toObject(ChatTopic.class).getTitle())), +asyncClient.listTopics("general").byPage(10).subscribe( + page -> page.getValue().forEach(topic -> System.out.println(topic.getTitle())), error -> System.err.println("Could not list topic pages: " + error.getMessage())); ``` -See [known generator issues](https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/webpubsub/azure-messaging-webpubsub-chat/KNOWN_ISSUES.md) for verification and removal of the -temporary test workaround. No paging customization is applied. - ### Service API versions The default is `WebPubSubChatServiceVersion.V2026_08_01_PREVIEW`. The library also diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceAsyncClient.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceAsyncClient.java index 1b5dc45cd5de5..3b7271585a512 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceAsyncClient.java +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceAsyncClient.java @@ -2034,9 +2034,16 @@ public PagedFlux listRooms(String continuationToken) { } PagedFlux pagedFluxResponse = listRooms(requestOptions); return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { - Flux> flux = (continuationTokenParam == null) - ? pagedFluxResponse.byPage().take(1) - : pagedFluxResponse.byPage(continuationTokenParam).take(1); + Flux> flux; + if (pageSizeParam == null) { + flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationTokenParam).take(1); + } else { + flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage(pageSizeParam).take(1) + : pagedFluxResponse.byPage(continuationTokenParam, pageSizeParam).take(1); + } return flux.map(pagedResponse -> new PagedResponseBase(pagedResponse.getRequest(), pagedResponse.getStatusCode(), pagedResponse.getHeaders(), pagedResponse.getValue() @@ -2064,9 +2071,16 @@ public PagedFlux listRooms() { RequestOptions requestOptions = new RequestOptions(); PagedFlux pagedFluxResponse = listRooms(requestOptions); return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { - Flux> flux = (continuationTokenParam == null) - ? pagedFluxResponse.byPage().take(1) - : pagedFluxResponse.byPage(continuationTokenParam).take(1); + Flux> flux; + if (pageSizeParam == null) { + flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationTokenParam).take(1); + } else { + flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage(pageSizeParam).take(1) + : pagedFluxResponse.byPage(continuationTokenParam, pageSizeParam).take(1); + } return flux.map(pagedResponse -> new PagedResponseBase(pagedResponse.getRequest(), pagedResponse.getStatusCode(), pagedResponse.getHeaders(), pagedResponse.getValue() @@ -2100,9 +2114,16 @@ public PagedFlux listTopics(String roomId, String continuationToken) } PagedFlux pagedFluxResponse = listTopics(roomId, requestOptions); return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { - Flux> flux = (continuationTokenParam == null) - ? pagedFluxResponse.byPage().take(1) - : pagedFluxResponse.byPage(continuationTokenParam).take(1); + Flux> flux; + if (pageSizeParam == null) { + flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationTokenParam).take(1); + } else { + flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage(pageSizeParam).take(1) + : pagedFluxResponse.byPage(continuationTokenParam, pageSizeParam).take(1); + } return flux.map(pagedResponse -> new PagedResponseBase(pagedResponse.getRequest(), pagedResponse.getStatusCode(), pagedResponse.getHeaders(), pagedResponse.getValue() @@ -2132,9 +2153,16 @@ public PagedFlux listTopics(String roomId) { RequestOptions requestOptions = new RequestOptions(); PagedFlux pagedFluxResponse = listTopics(roomId, requestOptions); return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { - Flux> flux = (continuationTokenParam == null) - ? pagedFluxResponse.byPage().take(1) - : pagedFluxResponse.byPage(continuationTokenParam).take(1); + Flux> flux; + if (pageSizeParam == null) { + flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationTokenParam).take(1); + } else { + flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage(pageSizeParam).take(1) + : pagedFluxResponse.byPage(continuationTokenParam, pageSizeParam).take(1); + } return flux.map(pagedResponse -> new PagedResponseBase(pagedResponse.getRequest(), pagedResponse.getStatusCode(), pagedResponse.getHeaders(), pagedResponse.getValue() @@ -2368,9 +2396,16 @@ public PagedFlux listUsers(String continuationToken) { } PagedFlux pagedFluxResponse = listUsers(requestOptions); return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { - Flux> flux = (continuationTokenParam == null) - ? pagedFluxResponse.byPage().take(1) - : pagedFluxResponse.byPage(continuationTokenParam).take(1); + Flux> flux; + if (pageSizeParam == null) { + flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationTokenParam).take(1); + } else { + flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage(pageSizeParam).take(1) + : pagedFluxResponse.byPage(continuationTokenParam, pageSizeParam).take(1); + } return flux.map(pagedResponse -> new PagedResponseBase(pagedResponse.getRequest(), pagedResponse.getStatusCode(), pagedResponse.getHeaders(), pagedResponse.getValue() @@ -2398,9 +2433,16 @@ public PagedFlux listUsers() { RequestOptions requestOptions = new RequestOptions(); PagedFlux pagedFluxResponse = listUsers(requestOptions); return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { - Flux> flux = (continuationTokenParam == null) - ? pagedFluxResponse.byPage().take(1) - : pagedFluxResponse.byPage(continuationTokenParam).take(1); + Flux> flux; + if (pageSizeParam == null) { + flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationTokenParam).take(1); + } else { + flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage(pageSizeParam).take(1) + : pagedFluxResponse.byPage(continuationTokenParam, pageSizeParam).take(1); + } return flux.map(pagedResponse -> new PagedResponseBase(pagedResponse.getRequest(), pagedResponse.getStatusCode(), pagedResponse.getHeaders(), pagedResponse.getValue() @@ -2430,9 +2472,16 @@ public PagedFlux listRoomsForUser(String userId) { RequestOptions requestOptions = new RequestOptions(); PagedFlux pagedFluxResponse = listRoomsForUser(userId, requestOptions); return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { - Flux> flux = (continuationTokenParam == null) - ? pagedFluxResponse.byPage().take(1) - : pagedFluxResponse.byPage(continuationTokenParam).take(1); + Flux> flux; + if (pageSizeParam == null) { + flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationTokenParam).take(1); + } else { + flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage(pageSizeParam).take(1) + : pagedFluxResponse.byPage(continuationTokenParam, pageSizeParam).take(1); + } return flux.map(pagedResponse -> new PagedResponseBase(pagedResponse.getRequest(), pagedResponse.getStatusCode(), pagedResponse.getHeaders(), pagedResponse.getValue() @@ -2466,9 +2515,16 @@ public PagedFlux listRoomsForUser(String userId, String continuati } PagedFlux pagedFluxResponse = listRoomsForUser(userId, requestOptions); return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { - Flux> flux = (continuationTokenParam == null) - ? pagedFluxResponse.byPage().take(1) - : pagedFluxResponse.byPage(continuationTokenParam).take(1); + Flux> flux; + if (pageSizeParam == null) { + flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationTokenParam).take(1); + } else { + flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage(pageSizeParam).take(1) + : pagedFluxResponse.byPage(continuationTokenParam, pageSizeParam).take(1); + } return flux.map(pagedResponse -> new PagedResponseBase(pagedResponse.getRequest(), pagedResponse.getStatusCode(), pagedResponse.getHeaders(), pagedResponse.getValue() diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/samples/java/com/azure/messaging/webpubsub/chat/WebPubSubChatSamples.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/samples/java/com/azure/messaging/webpubsub/chat/WebPubSubChatSamples.java index c0a7cb9160856..d995500b6cda7 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/samples/java/com/azure/messaging/webpubsub/chat/WebPubSubChatSamples.java +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/samples/java/com/azure/messaging/webpubsub/chat/WebPubSubChatSamples.java @@ -4,7 +4,6 @@ package com.azure.messaging.webpubsub.chat; import com.azure.core.credential.AzureKeyCredential; -import com.azure.core.http.rest.RequestOptions; import com.azure.identity.DefaultAzureCredentialBuilder; import com.azure.messaging.webpubsub.chat.models.BuiltInChatRoles; import com.azure.messaging.webpubsub.chat.models.ChatPermission; @@ -211,11 +210,11 @@ public void listTopicsAsync(WebPubSubChatServiceAsyncClient asyncClient) { // END: readme-sample-listChatTopicsAsync } - /** Uses protocol paging while the typed async page-size override is awaiting an upstream fix. */ + /** Lists typed topics asynchronously with an explicit page size. */ public void listTopicsAsyncByPage(WebPubSubChatServiceAsyncClient asyncClient) { // BEGIN: readme-sample-listChatTopicsAsyncByPage - asyncClient.listTopics("general", new RequestOptions()).byPage(10).subscribe( - page -> page.getValue().forEach(data -> System.out.println(data.toObject(ChatTopic.class).getTitle())), + asyncClient.listTopics("general").byPage(10).subscribe( + page -> page.getValue().forEach(topic -> System.out.println(topic.getTitle())), error -> System.err.println("Could not list topic pages: " + error.getMessage())); // END: readme-sample-listChatTopicsAsyncByPage } diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/ChatServiceAugustAsyncClientLiveTests.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/ChatServiceAugustAsyncClientLiveTests.java index 1520814e42eb2..037840fa32f8f 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/ChatServiceAugustAsyncClientLiveTests.java +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/ChatServiceAugustAsyncClientLiveTests.java @@ -6,8 +6,6 @@ import com.azure.core.exception.HttpResponseException; import com.azure.core.http.MatchConditions; import com.azure.core.http.rest.PagedResponse; -import com.azure.core.http.rest.RequestOptions; -import com.azure.core.util.BinaryData; import com.azure.messaging.webpubsub.chat.models.BuiltInChatRoles; import com.azure.messaging.webpubsub.chat.models.ChatRoom; import com.azure.messaging.webpubsub.chat.models.ChatRoomMember; @@ -76,15 +74,13 @@ public void canManageTopicsWithConditionsAndPagination() { assertEquals(412, stale.getResponse().getStatusCode()); asyncClient.createOrReplaceTopic(roomId, secondTopicId, new ChatTopic().setTitle("Second topic")).block(); - // Protocol paging preserves page size until microsoft/typespec#12149 is fixed. - List> pages - = asyncClient.listTopics(roomId, new RequestOptions()).byPage(1).take(2).collectList().block(); + List> pages + = asyncClient.listTopics(roomId).byPage(1).take(2).collectList().block(); assertEquals(2, pages.size()); assertEquals(1, pages.get(0).getValue().size()); assertNotNull(pages.get(0).getContinuationToken()); assertEquals(1, pages.get(1).getValue().size()); - assertNotEquals(pages.get(0).getValue().get(0).toObject(ChatTopic.class).getId(), - pages.get(1).getValue().get(0).toObject(ChatTopic.class).getId()); + assertNotEquals(pages.get(0).getValue().get(0).getId(), pages.get(1).getValue().get(0).getId()); List topicIds = asyncClient.listTopics(roomId).map(ChatTopic::getId).collectList().block(); assertTrue(topicIds.contains(firstTopicId)); assertTrue(topicIds.contains(secondTopicId)); @@ -113,20 +109,16 @@ public void canListRoomsAndUsersWithPagination() { .createOrReplaceUser(secondUserId, new HumanChatUser("Second user", BuiltInChatRoles.USER_NORMAL)) .block(); - List roomIds = asyncClient.listRooms(new RequestOptions()) + List roomIds = asyncClient.listRooms() .byPage(1) .flatMapIterable(PagedResponse::getValue) - .map(data -> data.toObject(ChatRoom.class).getId()) + .map(ChatRoom::getId) .collectList() .block(); assertTrue(roomIds.contains(firstRoomId)); assertTrue(roomIds.contains(secondRoomId)); - List users = entraAsyncClient.listUsers(new RequestOptions()) - .byPage(1) - .flatMapIterable(PagedResponse::getValue) - .map(data -> data.toObject(ChatUser.class)) - .collectList() - .block(); + List users + = entraAsyncClient.listUsers().byPage(1).flatMapIterable(PagedResponse::getValue).collectList().block(); assertTrue( users.stream().anyMatch(user -> firstUserId.equals(user.getId()) && user instanceof HumanChatUser)); assertTrue(users.stream().anyMatch(user -> secondUserId.equals(user.getId()))); @@ -157,14 +149,13 @@ public void canListRoomsForUserWithPagination() { .createOrReplaceRoomMember(secondRoomId, userId, new ChatRoomMember(BuiltInChatRoles.ROOM_MEMBER)) .block(); - List> pages - = asyncClient.listRoomsForUser(userId, new RequestOptions()).byPage(1).collectList().block(); + List> pages + = asyncClient.listRoomsForUser(userId).byPage(1).collectList().block(); assertEquals(2, pages.size()); assertEquals(1, pages.get(0).getValue().size()); assertNotNull(pages.get(0).getContinuationToken()); assertEquals(1, pages.get(1).getValue().size()); - assertNotEquals(pages.get(0).getValue().get(0).toObject(ChatUserRoom.class).getId(), - pages.get(1).getValue().get(0).toObject(ChatUserRoom.class).getId()); + assertNotEquals(pages.get(0).getValue().get(0).getId(), pages.get(1).getValue().get(0).getId()); List rooms = asyncClient.listRoomsForUser(userId).collectList().block(); assertEquals(2, rooms.size()); assertTrue(rooms.stream() diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/WebPubSubChatPaginationTests.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/WebPubSubChatPaginationTests.java index a8fed7894535e..023ebde785e4b 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/WebPubSubChatPaginationTests.java +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/WebPubSubChatPaginationTests.java @@ -11,7 +11,6 @@ import com.azure.core.http.rest.RequestOptions; import com.azure.core.test.http.MockHttpResponse; import com.azure.core.test.utils.MockTokenCredential; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; import reactor.core.publisher.Mono; @@ -36,7 +35,6 @@ public void syncPageSizeReachesFirstAndNextRequests(String operation) { assertPageSize(requests); } - @Disabled("Awaiting upstream Java generator fix: https://github.com/microsoft/typespec/issues/12149") @ParameterizedTest @ValueSource(strings = { "roles", "members", "messages", "rooms", "topics", "users", "userRooms" }) public void asyncPageSizeReachesFirstAndNextRequests(String operation) { From d0a2d314dc68a7047dcd0c1ab43ff5406b869ccd Mon Sep 17 00:00:00 2001 From: Zitong Yang Date: Fri, 23 Oct 2026 12:43:19 +1100 Subject: [PATCH 04/18] Fix Web PubSub Chat lifecycle documentation Correct request visibility and PATCH optionality across sync, async and implementation Javadocs while retaining response requiredness. Persist the documentation-only workaround in Java customization and cover regeneration and idempotence with regression tests. Related: Azure/typespec-azure#5721 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../CHANGELOG.md | 1 + .../KNOWN_ISSUES.md | 18 ++ .../customization.md | 11 + .../customization/pom.xml | 9 + .../main/java/WebPubSubChatCustomization.java | 71 ++++++ .../java/WebPubSubChatDocumentationTests.java | 218 ++++++++++++++++++ .../chat/WebPubSubChatServiceAsyncClient.java | 58 ++--- .../chat/WebPubSubChatServiceClient.java | 58 ++--- .../WebPubSubChatServiceClientImpl.java | 148 +++++------- .../webpubsub/chat/models/ChatTopic.java | 2 +- 10 files changed, 417 insertions(+), 177 deletions(-) create mode 100644 sdk/webpubsub/azure-messaging-webpubsub-chat/customization/src/test/java/WebPubSubChatDocumentationTests.java diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/CHANGELOG.md b/sdk/webpubsub/azure-messaging-webpubsub-chat/CHANGELOG.md index 24977e72997b0..34511214a9fd0 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/CHANGELOG.md +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/CHANGELOG.md @@ -13,6 +13,7 @@ ### Bugs Fixed +- Corrected request and response Javadoc schemas to reflect read-only properties and partial-update optionality, and clarified that topic state is optional on creation. - Regenerated with Java emitter 0.48.1 to preserve page-size overrides on typed asynchronous collections, including continuation requests. ### Other Changes diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/KNOWN_ISSUES.md b/sdk/webpubsub/azure-messaging-webpubsub-chat/KNOWN_ISSUES.md index e476096f42c3a..ca4f104c57b0e 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/KNOWN_ISSUES.md +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/KNOWN_ISSUES.md @@ -1,5 +1,23 @@ # Web PubSub Chat generator regression coverage +## Workaround: lifecycle visibility and requiredness in Java documentation + +- **Tracking issue:** [Azure/typespec-azure#5721](https://github.com/Azure/typespec-azure/issues/5721). +- The Java customization corrects request schemas for all seven write operations + on the sync, async, and implementation clients. Read-only properties are + excluded from request bodies, PATCH properties are optional, and response + properties retain their requiredness. +- Topic state is optional on initial creation and can be supplied for updates. + PUT uses Create/Update visibility; this workaround does not exclude state + from PUT serialization. +- `customization/src/test/java/WebPubSubChatDocumentationTests.java` checks the + checked-in schemas, genuine required and optional fields, idempotence, and + preservation of executable code. Run it with + `mvn -f sdk/webpubsub/azure-messaging-webpubsub-chat/customization/pom.xml test`. + +This is a documentation-only workaround. Shared models, constructors, partial +PATCH serialization, public APIs, and service validation are unchanged. + ## Resolved: typed asynchronous page-size overrides - **Tracking issue:** [microsoft/typespec#12149](https://github.com/microsoft/typespec/issues/12149). diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/customization.md b/sdk/webpubsub/azure-messaging-webpubsub-chat/customization.md index 83e9d0168a860..262a2d89096da 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/customization.md +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/customization.md @@ -10,6 +10,17 @@ edit generated files unless the language generator explicitly requires a checked-in generated output update. Regenerate before final validation and verify that regeneration preserves the custom behavior. +### Java lifecycle documentation + +Keep the Java customization's lifecycle Javadoc corrections after generation +until [Azure/typespec-azure#5721](https://github.com/Azure/typespec-azure/issues/5721) +is resolved upstream. Request schemas must exclude read-only properties and +mark PATCH properties optional; response schemas must retain response +requiredness. Topic state is optional on initial creation and available during +updates, including PUT's Create/Update context. Do not change model constructors +or serialization to fix these documentation defects. Run the customization +module's `WebPubSubChatDocumentationTests` after updating generated output. + The existing Web PubSub **service** SDK for the target language is the source of truth for connection-string parsing, access-key authentication, reverse proxy behavior, and client access token generation. Reuse or share its implementation diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/pom.xml b/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/pom.xml index edc4a0ba3e77f..a2ccaa3d69013 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/pom.xml +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/pom.xml @@ -22,4 +22,13 @@ ../../../../ + + + + org.junit.jupiter + junit-jupiter + 5.13.4 + test + + \ No newline at end of file diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/src/main/java/WebPubSubChatCustomization.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/src/main/java/WebPubSubChatCustomization.java index a6f3ddbb3d340..67d3f85c2863b 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/src/main/java/WebPubSubChatCustomization.java +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/src/main/java/WebPubSubChatCustomization.java @@ -4,6 +4,8 @@ import com.azure.autorest.customization.Customization; import com.azure.autorest.customization.LibraryCustomization; import com.azure.autorest.customization.PackageCustomization; +import com.github.javaparser.StaticJavaParser; +import com.github.javaparser.ast.body.MethodDeclaration; import org.slf4j.Logger; /** Customizes the generated Azure Web PubSub Chat client library. */ @@ -32,9 +34,78 @@ public void customize(LibraryCustomization libraryCustomization, Logger logger) customizeTokenClient(chatPackage, "WebPubSubChatServiceClient"); customizeTokenClient(chatPackage, "WebPubSubChatServiceAsyncClient"); + customizeLifecycleDocumentation(libraryCustomization); removeTrailingJavadocWhitespace(libraryCustomization); } + static void customizeLifecycleDocumentation(LibraryCustomization libraryCustomization) { + String root = "src/main/java/com/azure/messaging/webpubsub/chat/"; + for (String file : new String[] { + "WebPubSubChatServiceClient.java", + "WebPubSubChatServiceAsyncClient.java", + "implementation/WebPubSubChatServiceClientImpl.java", + "models/ChatTopic.java" }) { + String path = root + file; + String source = libraryCustomization.getRawEditor().getFileContent(path); + libraryCustomization.getRawEditor().replaceFile(path, correctLifecycleDocumentation(source)); + } + } + + static String correctLifecycleDocumentation(String source) { + for (MethodDeclaration method : StaticJavaParser.parse(source).findAll(MethodDeclaration.class)) { + if (!method.getJavadocComment().isPresent()) { + continue; + } + String original = method.getJavadocComment().get().getContent(); + String corrected = original; + String responseHeading = "

Response Body Schema

"; + int responseStart = corrected.indexOf(responseHeading); + if (responseStart >= 0) { + corrected = corrected.substring(0, responseStart) + + corrected.substring(responseStart).replace("(Optional, Required on create)", "(Required)"); + } + int requestStart = corrected.indexOf("

Request Body Schema

"); + if (requestStart >= 0) { + if (responseStart < requestStart) { + throw new IllegalStateException("Missing response schema for " + method.getNameAsString()); + } + String request = corrected.substring(requestStart, responseStart); + String readOnlyFields; + String name = method.getNameAsString(); + if (name.startsWith("updateMessage")) { + readOnlyFields = "id|createdAt|etag"; + } else if (name.startsWith("createOrReplaceRole")) { + readOnlyFields = "name|etag"; + } else if (name.startsWith("createOrReplaceRoomMember")) { + readOnlyFields = "userId|etag"; + } else if (name.startsWith("createOrReplaceRoom")) { + readOnlyFields = "id|defaultConversation|etag"; + } else if (name.startsWith("createOrReplaceUser")) { + readOnlyFields = "id|etag"; + } else if (name.startsWith("createOrReplaceTopic") || name.startsWith("updateTopic")) { + readOnlyFields = "id|createdAt|createdBy|conversationId|etag"; + } else { + throw new IllegalStateException("Unrecognized request schema for " + name); + } + request = request.replaceAll("(?m)^\\h*\\*\\h+(?:" + readOnlyFields + "):[^\\r\\n]*\\R", ""); + request = request.replace("(Optional, Required on create)", + name.startsWith("update") ? "(Optional)" : "(Required)"); + if (name.startsWith("createOrReplaceTopic")) { + request = request.replaceAll("(state: [^\\r\\n]+)\\(Required\\)", "$1(Optional)"); + } + corrected = corrected.substring(0, requestStart) + request + corrected.substring(responseStart); + } + if (method.getNameAsString().equals("setState")) { + corrected = corrected.replace("Required when create the resource.", + "Optional when creating a topic. Set this property to change the topic state when updating it."); + } + if (!original.equals(corrected)) { + source = source.replace(original, corrected); + } + } + return source; + } + private static void customizeTokenClient(PackageCustomization chatPackage, String className) { chatPackage.getClass(className).customizeAst(ast -> { ast.getImports() diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/src/test/java/WebPubSubChatDocumentationTests.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/src/test/java/WebPubSubChatDocumentationTests.java new file mode 100644 index 0000000000000..afca5599c7574 --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/src/test/java/WebPubSubChatDocumentationTests.java @@ -0,0 +1,218 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +import com.github.javaparser.StaticJavaParser; +import com.github.javaparser.ast.body.MethodDeclaration; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; + +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Arrays; +import java.util.List; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +public class WebPubSubChatDocumentationTests { + private static final String REQUEST = "

Request Body Schema

"; + private static final String RESPONSE = "

Response Body Schema

"; + private static final Path SOURCE + = Paths.get("..", "src", "main", "java", "com", "azure", "messaging", "webpubsub", "chat"); + + @Test + public void generatedDocumentationMatchesCustomization() throws IOException { + for (String file : Arrays.asList("WebPubSubChatServiceClient.java", "WebPubSubChatServiceAsyncClient.java", + "implementation/WebPubSubChatServiceClientImpl.java", "models/ChatTopic.java")) { + String source = new String(Files.readAllBytes(SOURCE.resolve(file)), StandardCharsets.UTF_8); + assertEquals(source, WebPubSubChatCustomization.correctLifecycleDocumentation(source), file); + } + } + + @Test + public void allWriteSchemasRespectVisibility() throws IOException { + for (String file : Arrays.asList("WebPubSubChatServiceClient.java", "WebPubSubChatServiceAsyncClient.java", + "implementation/WebPubSubChatServiceClientImpl.java")) { + List methods + = StaticJavaParser.parse(SOURCE.resolve(file)).findAll(MethodDeclaration.class); + int requests = 0; + for (MethodDeclaration method : methods) { + String doc = method.getJavadocComment().map(comment -> comment.getContent()).orElse(""); + if (doc.contains(RESPONSE)) { + assertFalse(doc.substring(doc.indexOf(RESPONSE)).contains("Optional, Required on create"), + method.getNameAsString()); + } + if (!doc.contains(REQUEST)) { + continue; + } + requests++; + String request = doc.substring(doc.indexOf(REQUEST), doc.indexOf(RESPONSE)); + assertFalse(request.contains("etag:"), method.getNameAsString()); + assertFalse(request.contains("Required on create"), method.getNameAsString()); + for (String readOnly : Arrays.asList("id:", "name:", "userId:", "createdAt:", "defaultConversation:", + "conversationId:")) { + assertFalse(java.util.regex.Pattern.compile("(?m)^\\h*\\*\\h+" + readOnly).matcher(request).find(), + method.getNameAsString() + ": " + readOnly); + } + String name = method.getNameAsString(); + if (name.startsWith("updateMessage")) { + assertTrue(request.contains("createdBy: String (Optional)")); + assertTrue(request.contains("content (Optional)")); + assertTrue(request.contains("text: String (Optional)")); + assertTrue(request.contains("binary: byte[] (Optional)")); + assertTrue(doc.substring(doc.indexOf(RESPONSE)).contains("content (Required)")); + } else if (name.startsWith("updateTopic") || name.startsWith("createOrReplaceTopic")) { + assertFalse(request.contains("createdBy:")); + assertTrue(request + .contains("title: String (" + (name.startsWith("update") ? "Optional" : "Required") + ")")); + assertTrue(request.contains("state: String(Normal/Archived/SoftDeleted) (Optional)")); + assertTrue(doc.substring(doc.indexOf(RESPONSE)).contains("title: String (Required)")); + assertTrue(doc.substring(doc.indexOf(RESPONSE)) + .contains("state: String(Normal/Archived/SoftDeleted) (Required)")); + } else if (name.startsWith("createOrReplaceRole")) { + assertTrue(request.contains("permissions (Required)")); + } else if (name.startsWith("createOrReplaceRoomMember")) { + assertTrue(request.contains("roleName: String (Required)")); + } else if (name.startsWith("createOrReplaceRoom")) { + assertTrue(request.contains("title: String (Required)")); + } else if (name.startsWith("createOrReplaceUser")) { + assertTrue(request.contains("kind: String(Human) (Required)")); + assertTrue(request.contains("nickname: String (Required)")); + } + assertTrue(doc.contains("@param resource")); + assertTrue(doc.contains("If-Match")); + } + assertEquals(file.startsWith("implementation") ? 14 : 7, requests, file); + } + } + + @Test + public void repairsEmitterDocumentationWithoutChangingCode() { + String source = "class Example {\n" + "/**\n * " + REQUEST + "\n" + " * id: String (Required)\n" + + " * title: String (Optional, Required on create)\n" + + " * state: String(Normal/Archived/SoftDeleted) (Optional, Required on create)\n" + + " * etag: String (Required)\n" + " * " + RESPONSE + "\n" + " * id: String (Required)\n" + + " * title: String (Optional, Required on create)\n" + + " * state: String(Normal/Archived/SoftDeleted) (Optional, Required on create)\n" + + " * @param roomId Room identifier.\n */\n" + + "public void updateTopicWithResponse(String roomId) { System.out.println(roomId); }\n}"; + String corrected = WebPubSubChatCustomization.correctLifecycleDocumentation(source); + assertFalse(corrected.equals(source)); + assertTrue(corrected.contains("title: String (Optional)")); + assertTrue(corrected.contains("title: String (Required)")); + assertEquals(corrected, WebPubSubChatCustomization.correctLifecycleDocumentation(corrected)); + assertEquals(withoutComments(source), withoutComments(corrected)); + } + + @ParameterizedTest + @ValueSource( + strings = { + "updateMessage", + "updateTopic", + "createOrReplaceTopic", + "createOrReplaceRole", + "createOrReplaceRoom", + "createOrReplaceRoomMember", + "createOrReplaceUser" }) + public void repairsAllWriteOperations(String operation) { + String fields; + String readOnly; + switch (operation) { + case "updateMessage": + fields = "createdBy: String (Optional, Required on create)\n" + + " * content (Optional, Required on create): {\n" + + " * text: String (Optional)\n * }"; + readOnly = "id,createdAt,etag"; + break; + + case "updateTopic": + case "createOrReplaceTopic": + fields = "title: String (Optional, Required on create)\n" + + " * state: String(Normal/Archived/SoftDeleted) (Optional, Required on create)"; + readOnly = "id,createdAt,createdBy,conversationId,etag"; + break; + + case "createOrReplaceRole": + fields = "permissions (Required): []"; + readOnly = "name,etag"; + break; + + case "createOrReplaceRoom": + fields = "title: String (Required)"; + readOnly = "id,defaultConversation,etag"; + break; + + case "createOrReplaceRoomMember": + fields = "roleName: String (Required)"; + readOnly = "userId,etag"; + break; + + case "createOrReplaceUser": + fields = "nickname: String (Required)\n * kind: String(Human) (Required)"; + readOnly = "id,etag"; + break; + + default: + throw new IllegalArgumentException(operation); + } + String schema = " * " + fields + "\n"; + for (String field : readOnly.split(",")) { + schema += " * " + field + ": String (Required)\n"; + } + for (String suffix : Arrays.asList("WithResponse", "WithResponseAsync")) { + String source = "class Example {\n/**\n * " + REQUEST + "\n" + schema + " * " + RESPONSE + "\n" + schema + + " * @param resource The resource.\n */\nvoid " + operation + suffix + "(Object resource) {}\n}"; + String corrected = WebPubSubChatCustomization.correctLifecycleDocumentation(source); + String request = corrected.substring(corrected.indexOf(REQUEST), corrected.indexOf(RESPONSE)); + String response = corrected.substring(corrected.indexOf(RESPONSE)); + for (String field : readOnly.split(",")) { + assertFalse(request.contains(" * " + field + ":"), operation + ": " + field); + assertTrue(response.contains(" * " + field + ":"), operation + ": " + field); + } + assertFalse(corrected.contains("Optional, Required on create"), operation); + if (operation.equals("updateMessage")) { + assertTrue(request.contains("content (Optional)")); + assertTrue(response.contains("content (Required)")); + assertTrue(response.contains("text: String (Optional)")); + } else if (operation.endsWith("Topic")) { + assertTrue(request + .contains("title: String (" + (operation.startsWith("update") ? "Optional" : "Required") + ")")); + assertTrue(request.contains("state: String(Normal/Archived/SoftDeleted) (Optional)")); + assertTrue(response.contains("title: String (Required)")); + assertTrue(response.contains("state: String(Normal/Archived/SoftDeleted) (Required)")); + } else { + assertTrue(request.contains(fields)); + } + assertEquals(corrected, WebPubSubChatCustomization.correctLifecycleDocumentation(corrected), operation); + assertEquals(withoutComments(source), withoutComments(corrected), operation); + } + } + + @Test + public void stateSetterDoesNotRequireStateOnCreate() throws IOException { + MethodDeclaration setter = StaticJavaParser.parse(SOURCE.resolve("models/ChatTopic.java")) + .findAll(MethodDeclaration.class) + .stream() + .filter(method -> method.getNameAsString().equals("setState")) + .findFirst() + .get(); + String doc = setter.getJavadocComment().get().getContent(); + assertTrue(doc.contains("Optional when creating a topic.")); + assertFalse(doc.contains("Required when create")); + String original = "/**\n *

Required when create the resource.

\n */\n" + + "class Example { /**

Required when create the resource.

*/ void setState() {} }"; + assertTrue(WebPubSubChatCustomization.correctLifecycleDocumentation(original) + .contains("Optional when creating a topic.")); + } + + private static String withoutComments(String source) { + com.github.javaparser.ast.CompilationUnit ast = StaticJavaParser.parse(source); + ast.getAllContainedComments().forEach(comment -> comment.remove()); + return ast.toString(); + } +} diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceAsyncClient.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceAsyncClient.java index 3b7271585a512..b058960fea117 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceAsyncClient.java +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceAsyncClient.java @@ -103,8 +103,8 @@ public Mono> getConversationWithResponse(String conversatio * {@code * { * id: String (Required) - * createdBy: String (Optional, Required on create) - * content (Optional, Required on create): { + * createdBy: String (Required) + * content (Required): { * text: String (Optional) * binary: byte[] (Optional) * } @@ -174,14 +174,11 @@ public Mono> deleteMessageWithResponse(String conversationId, Str *
      * {@code
      * {
-     *     id: String (Required)
-     *     createdBy: String (Optional, Required on create)
-     *     content (Optional, Required on create): {
+     *     createdBy: String (Optional)
+     *     content (Optional): {
      *         text: String (Optional)
      *         binary: byte[] (Optional)
      *     }
-     *     createdAt: OffsetDateTime (Required)
-     *     etag: String (Required)
      * }
      * }
      * 
@@ -192,8 +189,8 @@ public Mono> deleteMessageWithResponse(String conversationId, Str * {@code * { * id: String (Required) - * createdBy: String (Optional, Required on create) - * content (Optional, Required on create): { + * createdBy: String (Required) + * content (Required): { * text: String (Optional) * binary: byte[] (Optional) * } @@ -311,11 +308,9 @@ public Mono> getRoleWithResponse(String roleName, RequestOp *
      * {@code
      * {
-     *     name: String (Required)
      *     permissions (Required): [
      *         String(user.create_room/user.fetch_all_rooms/room.publish_message/room.history/room.invite/room.remove_user) (Required)
      *     ]
-     *     etag: String (Required)
      * }
      * }
      * 
@@ -406,10 +401,7 @@ public Mono> deleteRoleWithResponse(String roleName, RequestOptio *
      * {@code
      * {
-     *     id: String (Required)
      *     title: String (Required)
-     *     defaultConversation: String (Required)
-     *     etag: String (Required)
      * }
      * }
      * 
@@ -559,9 +551,7 @@ public PagedFlux listRoomMembers(String roomId, RequestOptions reque *
      * {@code
      * {
-     *     userId: String (Required)
      *     roleName: String (Required)
-     *     etag: String (Required)
      * }
      * }
      * 
@@ -686,9 +676,7 @@ public Mono> getUserWithResponse(String userId, RequestOpti * {@code * { * kind: String(Human) (Required) - * id: String (Required) * nickname: String (Required) - * etag: String (Required) * } * } * @@ -1715,10 +1703,10 @@ public PagedFlux listRooms(RequestOptions requestOptions) { * {@code * { * id: String (Required) - * title: String (Optional, Required on create) + * title: String (Required) * createdAt: OffsetDateTime (Required) * createdBy: String (Required) - * state: String(Normal/Archived/SoftDeleted) (Optional, Required on create) + * state: String(Normal/Archived/SoftDeleted) (Required) * conversationId: String (Required) * etag: String (Required) * } @@ -1758,13 +1746,8 @@ public PagedFlux listTopics(String roomId, RequestOptions requestOpt *
      * {@code
      * {
-     *     id: String (Required)
-     *     title: String (Optional, Required on create)
-     *     createdAt: OffsetDateTime (Required)
-     *     createdBy: String (Required)
-     *     state: String(Normal/Archived/SoftDeleted) (Optional, Required on create)
-     *     conversationId: String (Required)
-     *     etag: String (Required)
+     *     title: String (Required)
+     *     state: String(Normal/Archived/SoftDeleted) (Optional)
      * }
      * }
      * 
@@ -1775,10 +1758,10 @@ public PagedFlux listTopics(String roomId, RequestOptions requestOpt * {@code * { * id: String (Required) - * title: String (Optional, Required on create) + * title: String (Required) * createdAt: OffsetDateTime (Required) * createdBy: String (Required) - * state: String(Normal/Archived/SoftDeleted) (Optional, Required on create) + * state: String(Normal/Archived/SoftDeleted) (Required) * conversationId: String (Required) * etag: String (Required) * } @@ -1817,10 +1800,10 @@ public Mono> createOrReplaceTopicWithResponse(String roomId * {@code * { * id: String (Required) - * title: String (Optional, Required on create) + * title: String (Required) * createdAt: OffsetDateTime (Required) * createdBy: String (Required) - * state: String(Normal/Archived/SoftDeleted) (Optional, Required on create) + * state: String(Normal/Archived/SoftDeleted) (Required) * conversationId: String (Required) * etag: String (Required) * } @@ -1860,13 +1843,8 @@ public Mono> getTopicWithResponse(String roomId, String top *
      * {@code
      * {
-     *     id: String (Required)
-     *     title: String (Optional, Required on create)
-     *     createdAt: OffsetDateTime (Required)
-     *     createdBy: String (Required)
-     *     state: String(Normal/Archived/SoftDeleted) (Optional, Required on create)
-     *     conversationId: String (Required)
-     *     etag: String (Required)
+     *     title: String (Optional)
+     *     state: String(Normal/Archived/SoftDeleted) (Optional)
      * }
      * }
      * 
@@ -1877,10 +1855,10 @@ public Mono> getTopicWithResponse(String roomId, String top * {@code * { * id: String (Required) - * title: String (Optional, Required on create) + * title: String (Required) * createdAt: OffsetDateTime (Required) * createdBy: String (Required) - * state: String(Normal/Archived/SoftDeleted) (Optional, Required on create) + * state: String(Normal/Archived/SoftDeleted) (Required) * conversationId: String (Required) * etag: String (Required) * } diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceClient.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceClient.java index 2551384dd5872..4edc65013d833 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceClient.java +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceClient.java @@ -96,8 +96,8 @@ public Response getConversationWithResponse(String conversationId, R * {@code * { * id: String (Required) - * createdBy: String (Optional, Required on create) - * content (Optional, Required on create): { + * createdBy: String (Required) + * content (Required): { * text: String (Optional) * binary: byte[] (Optional) * } @@ -167,14 +167,11 @@ public Response deleteMessageWithResponse(String conversationId, String me *
      * {@code
      * {
-     *     id: String (Required)
-     *     createdBy: String (Optional, Required on create)
-     *     content (Optional, Required on create): {
+     *     createdBy: String (Optional)
+     *     content (Optional): {
      *         text: String (Optional)
      *         binary: byte[] (Optional)
      *     }
-     *     createdAt: OffsetDateTime (Required)
-     *     etag: String (Required)
      * }
      * }
      * 
@@ -185,8 +182,8 @@ public Response deleteMessageWithResponse(String conversationId, String me * {@code * { * id: String (Required) - * createdBy: String (Optional, Required on create) - * content (Optional, Required on create): { + * createdBy: String (Required) + * content (Required): { * text: String (Optional) * binary: byte[] (Optional) * } @@ -304,11 +301,9 @@ public Response getRoleWithResponse(String roleName, RequestOptions *
      * {@code
      * {
-     *     name: String (Required)
      *     permissions (Required): [
      *         String(user.create_room/user.fetch_all_rooms/room.publish_message/room.history/room.invite/room.remove_user) (Required)
      *     ]
-     *     etag: String (Required)
      * }
      * }
      * 
@@ -398,10 +393,7 @@ public Response deleteRoleWithResponse(String roleName, RequestOptions req *
      * {@code
      * {
-     *     id: String (Required)
      *     title: String (Required)
-     *     defaultConversation: String (Required)
-     *     etag: String (Required)
      * }
      * }
      * 
@@ -551,9 +543,7 @@ public PagedIterable listRoomMembers(String roomId, RequestOptions r *
      * {@code
      * {
-     *     userId: String (Required)
      *     roleName: String (Required)
-     *     etag: String (Required)
      * }
      * }
      * 
@@ -677,9 +667,7 @@ public Response getUserWithResponse(String userId, RequestOptions re * {@code * { * kind: String(Human) (Required) - * id: String (Required) * nickname: String (Required) - * etag: String (Required) * } * } * @@ -1571,10 +1559,10 @@ public PagedIterable listRooms(RequestOptions requestOptions) { * {@code * { * id: String (Required) - * title: String (Optional, Required on create) + * title: String (Required) * createdAt: OffsetDateTime (Required) * createdBy: String (Required) - * state: String(Normal/Archived/SoftDeleted) (Optional, Required on create) + * state: String(Normal/Archived/SoftDeleted) (Required) * conversationId: String (Required) * etag: String (Required) * } @@ -1614,13 +1602,8 @@ public PagedIterable listTopics(String roomId, RequestOptions reques *
      * {@code
      * {
-     *     id: String (Required)
-     *     title: String (Optional, Required on create)
-     *     createdAt: OffsetDateTime (Required)
-     *     createdBy: String (Required)
-     *     state: String(Normal/Archived/SoftDeleted) (Optional, Required on create)
-     *     conversationId: String (Required)
-     *     etag: String (Required)
+     *     title: String (Required)
+     *     state: String(Normal/Archived/SoftDeleted) (Optional)
      * }
      * }
      * 
@@ -1631,10 +1614,10 @@ public PagedIterable listTopics(String roomId, RequestOptions reques * {@code * { * id: String (Required) - * title: String (Optional, Required on create) + * title: String (Required) * createdAt: OffsetDateTime (Required) * createdBy: String (Required) - * state: String(Normal/Archived/SoftDeleted) (Optional, Required on create) + * state: String(Normal/Archived/SoftDeleted) (Required) * conversationId: String (Required) * etag: String (Required) * } @@ -1673,10 +1656,10 @@ public Response createOrReplaceTopicWithResponse(String roomId, Stri * {@code * { * id: String (Required) - * title: String (Optional, Required on create) + * title: String (Required) * createdAt: OffsetDateTime (Required) * createdBy: String (Required) - * state: String(Normal/Archived/SoftDeleted) (Optional, Required on create) + * state: String(Normal/Archived/SoftDeleted) (Required) * conversationId: String (Required) * etag: String (Required) * } @@ -1715,13 +1698,8 @@ public Response getTopicWithResponse(String roomId, String topicId, *
      * {@code
      * {
-     *     id: String (Required)
-     *     title: String (Optional, Required on create)
-     *     createdAt: OffsetDateTime (Required)
-     *     createdBy: String (Required)
-     *     state: String(Normal/Archived/SoftDeleted) (Optional, Required on create)
-     *     conversationId: String (Required)
-     *     etag: String (Required)
+     *     title: String (Optional)
+     *     state: String(Normal/Archived/SoftDeleted) (Optional)
      * }
      * }
      * 
@@ -1732,10 +1710,10 @@ public Response getTopicWithResponse(String roomId, String topicId, * {@code * { * id: String (Required) - * title: String (Optional, Required on create) + * title: String (Required) * createdAt: OffsetDateTime (Required) * createdBy: String (Required) - * state: String(Normal/Archived/SoftDeleted) (Optional, Required on create) + * state: String(Normal/Archived/SoftDeleted) (Required) * conversationId: String (Required) * etag: String (Required) * } diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/implementation/WebPubSubChatServiceClientImpl.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/implementation/WebPubSubChatServiceClientImpl.java index a2a8f645b7db2..36f0d96e366ce 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/implementation/WebPubSubChatServiceClientImpl.java +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/implementation/WebPubSubChatServiceClientImpl.java @@ -977,8 +977,8 @@ public Response getConversationWithResponse(String conversationId, R * {@code * { * id: String (Required) - * createdBy: String (Optional, Required on create) - * content (Optional, Required on create): { + * createdBy: String (Required) + * content (Required): { * text: String (Optional) * binary: byte[] (Optional) * } @@ -1026,8 +1026,8 @@ private Mono> listMessagesSinglePageAsync(String conve * {@code * { * id: String (Required) - * createdBy: String (Optional, Required on create) - * content (Optional, Required on create): { + * createdBy: String (Required) + * content (Required): { * text: String (Optional) * binary: byte[] (Optional) * } @@ -1092,8 +1092,8 @@ public PagedFlux listMessagesAsync(String conversationId, RequestOpt * {@code * { * id: String (Required) - * createdBy: String (Optional, Required on create) - * content (Optional, Required on create): { + * createdBy: String (Required) + * content (Required): { * text: String (Optional) * binary: byte[] (Optional) * } @@ -1138,8 +1138,8 @@ private PagedResponse listMessagesSinglePage(String conversationId, * {@code * { * id: String (Required) - * createdBy: String (Optional, Required on create) - * content (Optional, Required on create): { + * createdBy: String (Required) + * content (Required): { * text: String (Optional) * binary: byte[] (Optional) * } @@ -1261,14 +1261,11 @@ public Response deleteMessageWithResponse(String conversationId, String me *
      * {@code
      * {
-     *     id: String (Required)
-     *     createdBy: String (Optional, Required on create)
-     *     content (Optional, Required on create): {
+     *     createdBy: String (Optional)
+     *     content (Optional): {
      *         text: String (Optional)
      *         binary: byte[] (Optional)
      *     }
-     *     createdAt: OffsetDateTime (Required)
-     *     etag: String (Required)
      * }
      * }
      * 
@@ -1279,8 +1276,8 @@ public Response deleteMessageWithResponse(String conversationId, String me * {@code * { * id: String (Required) - * createdBy: String (Optional, Required on create) - * content (Optional, Required on create): { + * createdBy: String (Required) + * content (Required): { * text: String (Optional) * binary: byte[] (Optional) * } @@ -1334,14 +1331,11 @@ public Mono> updateMessageWithResponseAsync(String conversa *
      * {@code
      * {
-     *     id: String (Required)
-     *     createdBy: String (Optional, Required on create)
-     *     content (Optional, Required on create): {
+     *     createdBy: String (Optional)
+     *     content (Optional): {
      *         text: String (Optional)
      *         binary: byte[] (Optional)
      *     }
-     *     createdAt: OffsetDateTime (Required)
-     *     etag: String (Required)
      * }
      * }
      * 
@@ -1352,8 +1346,8 @@ public Mono> updateMessageWithResponseAsync(String conversa * {@code * { * id: String (Required) - * createdBy: String (Optional, Required on create) - * content (Optional, Required on create): { + * createdBy: String (Required) + * content (Required): { * text: String (Optional) * binary: byte[] (Optional) * } @@ -1670,11 +1664,9 @@ public Response getRoleWithResponse(String roleName, RequestOptions *
      * {@code
      * {
-     *     name: String (Required)
      *     permissions (Required): [
      *         String(user.create_room/user.fetch_all_rooms/room.publish_message/room.history/room.invite/room.remove_user) (Required)
      *     ]
-     *     etag: String (Required)
      * }
      * }
      * 
@@ -1739,11 +1731,9 @@ public Mono> createOrReplaceRoleWithResponseAsync(String ro *
      * {@code
      * {
-     *     name: String (Required)
      *     permissions (Required): [
      *         String(user.create_room/user.fetch_all_rooms/room.publish_message/room.history/room.invite/room.remove_user) (Required)
      *     ]
-     *     etag: String (Required)
      * }
      * }
      * 
@@ -2060,10 +2050,7 @@ public PagedIterable listRooms(RequestOptions requestOptions) { *
      * {@code
      * {
-     *     id: String (Required)
      *     title: String (Required)
-     *     defaultConversation: String (Required)
-     *     etag: String (Required)
      * }
      * }
      * 
@@ -2126,10 +2113,7 @@ public Mono> createOrReplaceRoomWithResponseAsync(String ro *
      * {@code
      * {
-     *     id: String (Required)
      *     title: String (Required)
-     *     defaultConversation: String (Required)
-     *     etag: String (Required)
      * }
      * }
      * 
@@ -2302,10 +2286,10 @@ public Response deleteRoomWithResponse(String roomId, RequestOptions reque * {@code * { * id: String (Required) - * title: String (Optional, Required on create) + * title: String (Required) * createdAt: OffsetDateTime (Required) * createdBy: String (Required) - * state: String(Normal/Archived/SoftDeleted) (Optional, Required on create) + * state: String(Normal/Archived/SoftDeleted) (Required) * conversationId: String (Required) * etag: String (Required) * } @@ -2347,10 +2331,10 @@ private Mono> listTopicsSinglePageAsync(String roomId, * {@code * { * id: String (Required) - * title: String (Optional, Required on create) + * title: String (Required) * createdAt: OffsetDateTime (Required) * createdBy: String (Required) - * state: String(Normal/Archived/SoftDeleted) (Optional, Required on create) + * state: String(Normal/Archived/SoftDeleted) (Required) * conversationId: String (Required) * etag: String (Required) * } @@ -2410,10 +2394,10 @@ public PagedFlux listTopicsAsync(String roomId, RequestOptions reque * {@code * { * id: String (Required) - * title: String (Optional, Required on create) + * title: String (Required) * createdAt: OffsetDateTime (Required) * createdBy: String (Required) - * state: String(Normal/Archived/SoftDeleted) (Optional, Required on create) + * state: String(Normal/Archived/SoftDeleted) (Required) * conversationId: String (Required) * etag: String (Required) * } @@ -2453,10 +2437,10 @@ private PagedResponse listTopicsSinglePage(String roomId, RequestOpt * {@code * { * id: String (Required) - * title: String (Optional, Required on create) + * title: String (Required) * createdAt: OffsetDateTime (Required) * createdBy: String (Required) - * state: String(Normal/Archived/SoftDeleted) (Optional, Required on create) + * state: String(Normal/Archived/SoftDeleted) (Required) * conversationId: String (Required) * etag: String (Required) * } @@ -2519,13 +2503,8 @@ public PagedIterable listTopics(String roomId, RequestOptions reques *
      * {@code
      * {
-     *     id: String (Required)
-     *     title: String (Optional, Required on create)
-     *     createdAt: OffsetDateTime (Required)
-     *     createdBy: String (Required)
-     *     state: String(Normal/Archived/SoftDeleted) (Optional, Required on create)
-     *     conversationId: String (Required)
-     *     etag: String (Required)
+     *     title: String (Required)
+     *     state: String(Normal/Archived/SoftDeleted) (Optional)
      * }
      * }
      * 
@@ -2536,10 +2515,10 @@ public PagedIterable listTopics(String roomId, RequestOptions reques * {@code * { * id: String (Required) - * title: String (Optional, Required on create) + * title: String (Required) * createdAt: OffsetDateTime (Required) * createdBy: String (Required) - * state: String(Normal/Archived/SoftDeleted) (Optional, Required on create) + * state: String(Normal/Archived/SoftDeleted) (Required) * conversationId: String (Required) * etag: String (Required) * } @@ -2592,13 +2571,8 @@ public Mono> createOrReplaceTopicWithResponseAsync(String r *
      * {@code
      * {
-     *     id: String (Required)
-     *     title: String (Optional, Required on create)
-     *     createdAt: OffsetDateTime (Required)
-     *     createdBy: String (Required)
-     *     state: String(Normal/Archived/SoftDeleted) (Optional, Required on create)
-     *     conversationId: String (Required)
-     *     etag: String (Required)
+     *     title: String (Required)
+     *     state: String(Normal/Archived/SoftDeleted) (Optional)
      * }
      * }
      * 
@@ -2609,10 +2583,10 @@ public Mono> createOrReplaceTopicWithResponseAsync(String r * {@code * { * id: String (Required) - * title: String (Optional, Required on create) + * title: String (Required) * createdAt: OffsetDateTime (Required) * createdBy: String (Required) - * state: String(Normal/Archived/SoftDeleted) (Optional, Required on create) + * state: String(Normal/Archived/SoftDeleted) (Required) * conversationId: String (Required) * etag: String (Required) * } @@ -2653,10 +2627,10 @@ public Response createOrReplaceTopicWithResponse(String roomId, Stri * {@code * { * id: String (Required) - * title: String (Optional, Required on create) + * title: String (Required) * createdAt: OffsetDateTime (Required) * createdBy: String (Required) - * state: String(Normal/Archived/SoftDeleted) (Optional, Required on create) + * state: String(Normal/Archived/SoftDeleted) (Required) * conversationId: String (Required) * etag: String (Required) * } @@ -2688,10 +2662,10 @@ public Mono> getTopicWithResponseAsync(String roomId, Strin * {@code * { * id: String (Required) - * title: String (Optional, Required on create) + * title: String (Required) * createdAt: OffsetDateTime (Required) * createdBy: String (Required) - * state: String(Normal/Archived/SoftDeleted) (Optional, Required on create) + * state: String(Normal/Archived/SoftDeleted) (Required) * conversationId: String (Required) * etag: String (Required) * } @@ -2731,13 +2705,8 @@ public Response getTopicWithResponse(String roomId, String topicId, *
      * {@code
      * {
-     *     id: String (Required)
-     *     title: String (Optional, Required on create)
-     *     createdAt: OffsetDateTime (Required)
-     *     createdBy: String (Required)
-     *     state: String(Normal/Archived/SoftDeleted) (Optional, Required on create)
-     *     conversationId: String (Required)
-     *     etag: String (Required)
+     *     title: String (Optional)
+     *     state: String(Normal/Archived/SoftDeleted) (Optional)
      * }
      * }
      * 
@@ -2748,10 +2717,10 @@ public Response getTopicWithResponse(String roomId, String topicId, * {@code * { * id: String (Required) - * title: String (Optional, Required on create) + * title: String (Required) * createdAt: OffsetDateTime (Required) * createdBy: String (Required) - * state: String(Normal/Archived/SoftDeleted) (Optional, Required on create) + * state: String(Normal/Archived/SoftDeleted) (Required) * conversationId: String (Required) * etag: String (Required) * } @@ -2802,13 +2771,8 @@ public Mono> updateTopicWithResponseAsync(String roomId, St *
      * {@code
      * {
-     *     id: String (Required)
-     *     title: String (Optional, Required on create)
-     *     createdAt: OffsetDateTime (Required)
-     *     createdBy: String (Required)
-     *     state: String(Normal/Archived/SoftDeleted) (Optional, Required on create)
-     *     conversationId: String (Required)
-     *     etag: String (Required)
+     *     title: String (Optional)
+     *     state: String(Normal/Archived/SoftDeleted) (Optional)
      * }
      * }
      * 
@@ -2819,10 +2783,10 @@ public Mono> updateTopicWithResponseAsync(String roomId, St * {@code * { * id: String (Required) - * title: String (Optional, Required on create) + * title: String (Required) * createdAt: OffsetDateTime (Required) * createdBy: String (Required) - * state: String(Normal/Archived/SoftDeleted) (Optional, Required on create) + * state: String(Normal/Archived/SoftDeleted) (Required) * conversationId: String (Required) * etag: String (Required) * } @@ -3127,9 +3091,7 @@ public PagedIterable listRoomMembers(String roomId, RequestOptions r *
      * {@code
      * {
-     *     userId: String (Required)
      *     roleName: String (Required)
-     *     etag: String (Required)
      * }
      * }
      * 
@@ -3190,9 +3152,7 @@ public Mono> createOrReplaceRoomMemberWithResponseAsync(Str *
      * {@code
      * {
-     *     userId: String (Required)
      *     roleName: String (Required)
-     *     etag: String (Required)
      * }
      * }
      * 
@@ -3581,9 +3541,7 @@ public Response getUserWithResponse(String userId, RequestOptions re * {@code * { * kind: String(Human) (Required) - * id: String (Required) * nickname: String (Required) - * etag: String (Required) * } * } * @@ -3649,9 +3607,7 @@ public Mono> createOrReplaceUserWithResponseAsync(String us * {@code * { * kind: String(Human) (Required) - * id: String (Required) * nickname: String (Required) - * etag: String (Required) * } * } * @@ -4038,8 +3994,8 @@ public Response generateClientTokenWithResponse(String hub, RequestO * {@code * { * id: String (Required) - * createdBy: String (Optional, Required on create) - * content (Optional, Required on create): { + * createdBy: String (Required) + * content (Required): { * text: String (Optional) * binary: byte[] (Optional) * } @@ -4079,8 +4035,8 @@ private Mono> listMessagesNextSinglePageAsync(String n * {@code * { * id: String (Required) - * createdBy: String (Optional, Required on create) - * content (Optional, Required on create): { + * createdBy: String (Required) + * content (Required): { * text: String (Optional) * binary: byte[] (Optional) * } @@ -4261,10 +4217,10 @@ private PagedResponse listRoomsNextSinglePage(String nextLink, Reque * {@code * { * id: String (Required) - * title: String (Optional, Required on create) + * title: String (Required) * createdAt: OffsetDateTime (Required) * createdBy: String (Required) - * state: String(Normal/Archived/SoftDeleted) (Optional, Required on create) + * state: String(Normal/Archived/SoftDeleted) (Required) * conversationId: String (Required) * etag: String (Required) * } @@ -4301,10 +4257,10 @@ private Mono> listTopicsNextSinglePageAsync(String nex * {@code * { * id: String (Required) - * title: String (Optional, Required on create) + * title: String (Required) * createdAt: OffsetDateTime (Required) * createdBy: String (Required) - * state: String(Normal/Archived/SoftDeleted) (Optional, Required on create) + * state: String(Normal/Archived/SoftDeleted) (Required) * conversationId: String (Required) * etag: String (Required) * } diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/ChatTopic.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/ChatTopic.java index d817e95e3f586..bc88940454b2c 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/ChatTopic.java +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/ChatTopic.java @@ -167,7 +167,7 @@ public ChatTopicState getState() { /** * Set the state property: Current lifecycle state of the topic. - *

Required when create the resource.

+ *

Optional when creating a topic. Set this property to change the topic state when updating it.

* * @param state the state value to set. * @return the ChatTopic object itself. From c2788d0e104c028259098c99d63f50177a6bdd21 Mon Sep 17 00:00:00 2001 From: Zitong Yang Date: Tue, 27 Oct 2026 16:36:32 +1100 Subject: [PATCH 05/18] Make Web PubSub Chat message content mutually exclusive Use text and binary factories, preserve customization across regeneration, and update samples and regression tests. Remove obsolete package notes. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .../azure-messaging-webpubsub-chat/AGENTS.md | 16 - .../CHANGELOG.md | 2 + .../KNOWN_ISSUES.md | 49 --- .../azure-messaging-webpubsub-chat/README.md | 64 ++- .../customization.md | 383 ------------------ .../main/java/WebPubSubChatCustomization.java | 83 ++++ ...bChatMessageContentCustomizationTests.java | 58 +++ .../webpubsub/chat/models/MessageContent.java | 133 +++--- .../webpubsub/chat/WebPubSubChatSamples.java | 12 + .../chat/ChatServiceAsyncClientLiveTests.java | 4 +- .../chat/ChatServiceClientLiveTests.java | 7 +- .../webpubsub/chat/MessageContentTests.java | 177 ++++++++ 12 files changed, 415 insertions(+), 573 deletions(-) delete mode 100644 sdk/webpubsub/azure-messaging-webpubsub-chat/AGENTS.md delete mode 100644 sdk/webpubsub/azure-messaging-webpubsub-chat/KNOWN_ISSUES.md delete mode 100644 sdk/webpubsub/azure-messaging-webpubsub-chat/customization.md create mode 100644 sdk/webpubsub/azure-messaging-webpubsub-chat/customization/src/test/java/WebPubSubChatMessageContentCustomizationTests.java create mode 100644 sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/MessageContentTests.java diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/AGENTS.md b/sdk/webpubsub/azure-messaging-webpubsub-chat/AGENTS.md deleted file mode 100644 index 40410731e3229..0000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/AGENTS.md +++ /dev/null @@ -1,16 +0,0 @@ -# Web PubSub Chat development constraints - -Before changing tests, recording tests, regenerating, or releasing this package, -read [KNOWN_ISSUES.md](KNOWN_ISSUES.md) for resolved generator defects and their -regression coverage. Preserve the enabled typed async paging tests and strict -first-page/continuation assertions after regeneration. Do not restore the -removed protocol paging workaround or add a paging customization. - -Run live tests against a Chat-enabled resource in the TTL = 7 days subscription. -The server routing fix was verified in Central US EUAP on 2026-10-13 using the -complete sync/async live suite. All operations, including setup and cleanup, -use `2026-08-01-preview`; do not restore legacy-version clients or routing skips. -Upload sanitized recordings and verify clean-cache playback after test changes. - -Before publishing an issue, PR, or team message for this package, show the user -the destination and exact draft and obtain explicit approval. diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/CHANGELOG.md b/sdk/webpubsub/azure-messaging-webpubsub-chat/CHANGELOG.md index 34511214a9fd0..a11e3581047b0 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/CHANGELOG.md +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/CHANGELOG.md @@ -11,6 +11,8 @@ ### Breaking Changes +- Replaced the public `MessageContent` constructor and `setText`/`setBinary` methods with `MessageContent.fromText` and `MessageContent.fromBinary`. Each instance contains exactly one non-null representation; empty text and binary payloads remain supported. + ### Bugs Fixed - Corrected request and response Javadoc schemas to reflect read-only properties and partial-update optionality, and clarified that topic state is optional on creation. diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/KNOWN_ISSUES.md b/sdk/webpubsub/azure-messaging-webpubsub-chat/KNOWN_ISSUES.md deleted file mode 100644 index ca4f104c57b0e..0000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/KNOWN_ISSUES.md +++ /dev/null @@ -1,49 +0,0 @@ -# Web PubSub Chat generator regression coverage - -## Workaround: lifecycle visibility and requiredness in Java documentation - -- **Tracking issue:** [Azure/typespec-azure#5721](https://github.com/Azure/typespec-azure/issues/5721). -- The Java customization corrects request schemas for all seven write operations - on the sync, async, and implementation clients. Read-only properties are - excluded from request bodies, PATCH properties are optional, and response - properties retain their requiredness. -- Topic state is optional on initial creation and can be supplied for updates. - PUT uses Create/Update visibility; this workaround does not exclude state - from PUT serialization. -- `customization/src/test/java/WebPubSubChatDocumentationTests.java` checks the - checked-in schemas, genuine required and optional fields, idempotence, and - preservation of executable code. Run it with - `mvn -f sdk/webpubsub/azure-messaging-webpubsub-chat/customization/pom.xml test`. - -This is a documentation-only workaround. Shared models, constructors, partial -PATCH serialization, public APIs, and service validation are unchanged. - -## Resolved: typed asynchronous page-size overrides - -- **Tracking issue:** [microsoft/typespec#12149](https://github.com/microsoft/typespec/issues/12149). -- **Upstream fix:** [microsoft/typespec#12163](https://github.com/microsoft/typespec/pull/12163). -- **Verified emitter:** `@azure-tools/typespec-java` 0.48.1, adopted by the shared - repository configuration through [Azure/azure-sdk-for-java#50789](https://github.com/Azure/azure-sdk-for-java/pull/50789). -- **Verification:** Regenerated from the pinned `tsp-location.yaml` on - 2026-10-14. All 59 tests passed with no skips using an independently restored - recording cache, including all seven typed async page-size regression cases. - -The previous generator discarded `pageSizeParam` when converting protocol -`PagedFlux` responses to typed responses. The corrected generator -forwards page size on both first-page and continuation requests while preserving -default paging. No paging customization or manual generated-code fix is used. - -Keep `WebPubSubChatPaginationTests` enabled after future regeneration. Its -23 cases cover all seven sync, typed async, and protocol async list operations, -plus the sync/async `listRoomsForUser` continuation overload. The strict cases -assert `maxpagesize=1` on both requests and check the continuation token. - -The async live scenarios and samples now use typed paging directly. Their -request shapes remain compatible with the sanitized August API recordings; -do not weaken assertions or rewrite recordings to hide a paging regression. - -## Resolved: server routing - -All 14 sync/async live scenarios passed in Central US EUAP on 2026-10-13 with -`2026-08-01-preview`, including existing operations and setup/cleanup. The -legacy-version workaround, routing skips, and temporary skill were removed. diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/README.md b/sdk/webpubsub/azure-messaging-webpubsub-chat/README.md index 33728cbb3d2d0..3a5020a6ba255 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/README.md +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/README.md @@ -78,14 +78,9 @@ WebPubSubChatServiceClient client = new WebPubSubChatServiceClientBuilder() For more information, see [Authenticate Azure-hosted Java applications][azure_identity_auth] and [Microsoft Entra authorization for Azure Web PubSub][entra_authorization]. ## Key concepts - -### Client - -`WebPubSubChatServiceClient` is the entry point for managing Chat resources in one Web PubSub hub. Create one client for each endpoint and hub combination, and reuse the client for multiple operations. For nonblocking operations, use `WebPubSubChatServiceAsyncClient`, which is created by calling `buildAsyncClient` on the same builder. - ### Hub -A hub is a logical collection of WebSocket connections. A standard hub offers event-based real-time messaging through the Web PubSub subprotocol or a custom subprotocol. A chat hub adds built-in rooms, member management, message persistence, and chat-specific APIs. +A hub is a logical collection of WebSocket connections. A chat hub adds built-in rooms, member management, message persistence, and chat-specific APIs. This SDK applies only to chat hubs. Chat must be enabled on the target hub before the SDK can manage roles, users, rooms, members, conversations, or messages. @@ -97,38 +92,26 @@ User roles control operations such as creating rooms. Room roles control what a ### User -A user represents an application identity that can send and receive messages. A user is identified by a user ID and assigned a user role. A human user also has a nickname. Client access credentials associate WebSocket connections with a user ID. +A user represents an identity participating in chat, such as a human end user or an application. Client access credentials associate WebSocket connections with a user ID. ### Room A room groups users together and is the primary organizational unit for chat interactions. Every room has an automatically created default conversation. -### Topic - -A topic is a named conversation in a room. Each topic has a title, creation time, -creator, conversation ID, ETag, and lifecycle state. `ChatTopicState` includes -`NORMAL`, `ARCHIVED`, and `SOFT_DELETED`. The August API adds topic management; -topic deletion is a soft delete rather than a room deletion. - -### User's rooms - -`listRoomsForUser` returns read-only `ChatUserRoom` projections of the rooms -associated with a user. A projection contains the room ID, title, default -conversation ID, and ETag; it does not provide a separate room lifecycle. - ### Room member -A room member represents a user added to a room. Membership controls which users can receive and send messages in the room. Each room member is assigned a room role. +A room member represents a user added to a room. Membership controls which users can receive and send messages in the room. In the service API, each room member is assigned a room role. ### Conversation and message history -A conversation is a message thread that belongs to a room. Every room has a default conversation and can contain multiple conversations. +A conversation is an ordered message stream within a room. Every room has a default conversation, and additional named conversations can be created through topics. -Messages sent to a conversation are delivered in real time to the room's connected members. The Chat service manages ordering and persistence, allowing members to load message history after reconnecting or joining later. The service client can list, update, and delete persisted messages. +Messages sent to a conversation are delivered in real time to the room's connected members. The chat service manages ordering and persistence, allowing members to load message history after reconnecting or joining later. The service client can list, update, and delete persisted messages. -### Client access credentials +### Topic -`getClientAccessToken` returns a token and WebSocket connection URL. Clients configured with a connection string or access key sign the token locally. Clients configured with Microsoft Entra ID request the token from the Web PubSub service. +A topic represents a named conversation within a room. Topics can be created, +renamed, archived, and soft deleted independently of the room's default conversation. ## Examples @@ -275,6 +258,23 @@ client.listMessages(conversationId).forEach(message -> Use a conversation ID returned by room or topic creation. Message history queries return messages from latest to earliest. +### Update message content + +Use `MessageContent.fromText` or `MessageContent.fromBinary` to select exactly one +content representation. The getter for the unselected representation returns +`null`. Both factories accept empty content but reject `null`; binary arrays are +defensively copied. + +```java readme-sample-updateChatMessageContent +client.updateMessage(conversationId, messageId, + new ChatMessage().setContent(MessageContent.fromText("Updated message"))); +client.updateMessage(conversationId, messageId, + new ChatMessage().setContent(MessageContent.fromBinary(new byte[] { 1, 2, 3 }))); +``` + +The request contains only the selected content field. To explicitly set the +entire content to JSON `null` in a PATCH request, use `new ChatMessage().setContent(null)`. + ### Use the asynchronous client ```java readme-sample-createAsyncChatClient @@ -303,14 +303,6 @@ asyncClient.listTopics("general").byPage(10).subscribe( error -> System.err.println("Could not list topic pages: " + error.getMessage())); ``` -### Service API versions - -The default is `WebPubSubChatServiceVersion.V2026_08_01_PREVIEW`. The library also -supports `V2026_02_01_PREVIEW` for existing operations. Topic operations and the -new room/user listing operations require the August version. To select a version, -pass it to the builder's `serviceVersion` method. All operations are supported -with the August API; no separate client is needed for existing operations. - ## Troubleshooting ### Handle service errors @@ -321,12 +313,6 @@ Service operations throw `HttpResponseException` or a more specific subclass whe Enable SDK logging by setting the `AZURE_LOG_LEVEL` environment variable. See [Azure SDK logging][logging] for the supported levels and logging configuration. HTTP logs can contain sensitive information. Do not enable detailed logging in production without reviewing how logs are collected and protected, and never log connection strings, access keys, bearer tokens, or generated client access tokens. -### Authentication and authorization - -- Confirm that the endpoint and hub name identify the Web PubSub resource and Chat-enabled hub you intend to use. -- For Microsoft Entra ID, confirm that the principal has an appropriate Web PubSub data-plane role and that role assignment propagation has completed. -- Connection-string and access-key authentication are unavailable when local authentication is disabled on the Web PubSub resource. - ## Next steps diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/customization.md b/sdk/webpubsub/azure-messaging-webpubsub-chat/customization.md deleted file mode 100644 index 262a2d89096da..0000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/customization.md +++ /dev/null @@ -1,383 +0,0 @@ -# Web PubSub Chat SDK post-generation customization - -Use this instruction after generating a Web PubSub Chat service SDK from the -TypeSpec project. Apply it in each language repository using that repository's -Azure SDK naming, API, testing, and pipeline conventions. - -The generated REST operations and models remain generator-owned. Put the work -described here in customization, handwritten, or protocol-policy files. Do not -edit generated files unless the language generator explicitly requires a -checked-in generated output update. Regenerate before final validation and -verify that regeneration preserves the custom behavior. - -### Java lifecycle documentation - -Keep the Java customization's lifecycle Javadoc corrections after generation -until [Azure/typespec-azure#5721](https://github.com/Azure/typespec-azure/issues/5721) -is resolved upstream. Request schemas must exclude read-only properties and -mark PATCH properties optional; response schemas must retain response -requiredness. Topic state is optional on initial creation and available during -updates, including PUT's Create/Update context. Do not change model constructors -or serialization to fix these documentation defects. Run the customization -module's `WebPubSubChatDocumentationTests` after updating generated output. - -The existing Web PubSub **service** SDK for the target language is the source of -truth for connection-string parsing, access-key authentication, reverse proxy -behavior, and client access token generation. Reuse or share its implementation -instead of creating a second incompatible implementation in the Chat SDK. - -## 1. Establish the public client surface - -Keep the generated Microsoft Entra ID credential support. Follow the same -language's existing Web PubSub service SDK convention for client creation, -including constructor or builder shape, overload ordering, credential names, -options placement, defaults, validation, and sync/async client organization. -Do not copy the .NET constructor shape into a language that uses a different -idiom. Add that language's conventional equivalents of these inputs: - -- endpoint, hub, key credential -- endpoint, hub, key credential, client options -- connection string, hub -- connection string, hub, client options - -Use the same public key credential type and connection-string entry point as the -same language's Web PubSub service SDK. Parse a connection string with the same -parser and rules as that SDK. At minimum, read `Endpoint` and `AccessKey`, honor -supported optional fields such as `Port`, and construct the key credential from -the parsed access key. Do not log or retain the original connection string after -parsing. - -Validate endpoint, hub, credential, connection string, and options consistently -with the language's Azure SDK guidelines. Reject a null or empty hub. Options -omitted by the caller must receive the normal default instance. - -The client must retain enough state to create an internal Web PubSub service -client with the same endpoint, hub, credential, and relevant options. This -internal client owns client access token generation described below. - -## 2. Apply key credential authentication - -Follow the target language's Web PubSub service SDK convention exactly. Prefer -sharing the service SDK policy or helper. If that is not possible because it is -internal, move the implementation to a shared source/module owned by the Web -PubSub service SDK, or port it without changing behavior. - -For every Chat service REST request authenticated by key credential: - -1. Create a short-lived JWT signed with the UTF-8 bytes of the current key. -2. Use the same signing algorithm and JWT builder as the Web PubSub service SDK. -3. Set `nbf`, `iat`, `exp`, and `aud` claims. The policy token lifetime is five - minutes. -4. Set `Authorization: Bearer `. -5. Read the key for every token creation, or invalidate cached key bytes when - the credential is updated. Key rotation must work without recreating the - client. - -The `aud` claim is the complete original request URI, including scheme, -authority, path, and query string. It is not the reverse proxy URI. - -Place the authentication policy at the same pipeline position as the Web PubSub -service SDK. Ensure any reverse proxy rewrite records the original audience -before authentication creates the JWT. - -Microsoft Entra ID authentication continues to use the language's standard -bearer token policy and the scopes emitted for the Chat service. - -## 3. Add reverse proxy support - -Add the target language's conventional `reverseProxyEndpoint` client option. -The option must be set before client construction. - -When configured, install one per-call policy that: - -1. Captures the original request URI for authentication. -2. Replaces the request scheme and authority with the reverse proxy endpoint. -3. Preserves the original path and query without double escaping. -4. Sends the request to the rewritten URI. - -Do not add duplicate policies when an option is assigned more than once. A -request through the proxy must still have an access-key JWT whose audience is -the original Web PubSub URI. Entra ID requests must use the proxy while retaining -their normal bearer token. - -Copy the reverse proxy endpoint into the options used to construct the internal -Web PubSub service client. This propagation is required because Entra ID client -access token generation calls the service through that client. Do not silently -copy service name, API version, or other package-specific settings. Propagate -additional common options only when the target language can do so without -changing the inner client's service identity or duplicating policies. - -## 4. Generate client access credentials by delegation - -Expose the target language's idiomatic sync and async client access generation -API. Follow the Web PubSub service SDK's naming and result shape. For example, -some languages return a token response while the .NET Chat SDK exposes -`GetClientAccessUri` and returns a WebSocket URI containing `access_token`. - -Provide an options type with: - -- optional user ID -- token lifetime, defaulting to one hour - -Delegate to the internal Web PubSub service client. Do not duplicate its token -generation or service call in the Chat SDK. Pass the caller's user ID and token -lifetime, no initial groups, the default Web PubSub client protocol, and these -two fixed Web PubSub data roles: - -```text -webpubsub.getGroupState -webpubsub.setGroupState -``` - -These roles are service roles needed by a connected Chat client. They are not -Chat role names and are not caller-configurable. - -With a connection string or key credential, the Web PubSub service SDK normally -signs the client token locally. With Microsoft Entra ID, it normally calls the -service's generate-client-token operation. Preserve those service SDK semantics, -including cancellation, errors, endpoint conversion from HTTP(S) to WS(S), and -reverse proxy routing for the service call. - -## 5. Add built-in Chat constants - -Expose constants using the target language's normal constant container or enum -pattern. Use these exact wire values. - -Built-in roles: - -| Name | Value | -| --- | --- | -| User normal | `user.normal` | -| Room member | `room.member` | -| Room operator | `room.operator` | - -User permissions: - -| Name | Value | -| --- | --- | -| Create room | `user.create_room` | -| Fetch all rooms | `user.fetch_all_rooms` | - -Room permissions: - -| Name | Value | -| --- | --- | -| Invite user | `room.invite` | -| Remove user | `room.remove_user` | -| Read history | `room.history` | -| Publish message | `room.publish_message` | - -Do not expose planned permissions until the service supports them. In -particular, do not copy constants from an old API listing without checking the -handwritten source and current service behavior. Regenerate or update the -language's API surface artifact after adding these constants and verify that it -contains only supported values. - -## 6. Unit test the customization - -Add tests using the target language's Azure SDK test framework and mock -transport. Cover at least: - -- null and empty validation for every new constructor or builder path -- connection-string parsing, including endpoint/port handling -- key credential requests contain a five-minute signed bearer JWT -- JWT `aud` equals the full original request URI -- updating the key credential changes subsequently generated JWTs -- reverse proxy requests use the proxy authority and preserve path and query -- reverse proxy plus key credential keeps the original URI as JWT audience -- reverse proxy plus Entra ID sends the normal bearer token to the proxy -- client access generation forwards user ID, expiration, no groups, and exactly - the two required Web PubSub roles -- default client access lifetime is one hour -- sync and async client access APIs have equivalent behavior, where applicable -- key/connection-string access generation produces a WS(S) connection URL or - the language-standard equivalent result -- Entra ID access generation delegates to the service operation and honors the - reverse proxy endpoint -- every public role and permission constant has the exact expected wire value - -Decode JWTs in tests and assert claims rather than checking only that a token is -present. Use fake credentials and endpoints in unit tests. - -## 7. Add live and playback tests - -Create a test project/suite that participates in the language repository's -record/playback framework. Provision an Azure Web PubSub resource with a system -identity and persistent storage suitable for Chat message history. Export the -endpoint and connection string under stable test environment variable names. -For consistency with the .NET reference, use: - -```text -WPS_CHAT_ENDPOINT -WPS_CHAT_CONNECTION_STRING -``` - -Register the connection string as a secret and sanitize at least its -`AccessKey` value as Base64 secret data. Never commit a populated `.env` file, -credentials, deployed resource names tied to a developer, or raw access tokens. - -Exercise both async and sync clients when the language supports both. Live tests -must cover: - -- create, get, list, paginate, and delete roles -- create, get, and delete rooms -- get a room conversation and list messages -- empty message and member pages -- create, list, and delete room members -- create, get, and delete users -- generate a client access credential and verify its connection URL/result -- message send, list, update, and delete when the service and language client - support creating a message - -Use unique recorded IDs for mutable resources and clean up in `finally` or the -language equivalent. Cleanup must tolerate a resource that was not created or -was already deleted. Do not make a permanently skipped message test the only -coverage for message update/delete behavior; document the service limitation -and enable the scenario as soon as message creation is available. - -If a WebSocket helper is needed, connect with subprotocol -`json.webpubsub.azure.v1` and send the room message as a `sendToGroup` request: - -```json -{ - "type": "sendToGroup", - "group": "", - "dataType": "json", - "data": { - "type": "text", - "content": "" - } -} -``` - -Use a bounded timeout and wait for the service to persist the message before -asserting history. A test-only Chat client from another language may seed the -message when WebSocket handling is not practical, but pin its dependencies and -automate its invocation instead of requiring an undocumented manual step. - -## 8. Record and upload test assets - -Follow the target language repository's test-proxy setup. The required flow is: - -1. Create the package's `assets.json` using that repository's language prefix - and package path. -2. Deploy the test resources and set secret environment variables locally. -3. Run the complete live suite in record mode. -4. Inspect every recording for connection strings, access keys, bearer tokens, - user data, and unstable values. Add sanitizers and record again if any secret - remains. -5. Run the suite in playback mode without Azure credentials and verify that it - passes. -6. Upload the recordings with the repository-supported test-proxy executable: - - ```text - test-proxy push -a /assets.json - ``` - -7. Commit the updated `assets.json` tag. Do not commit the local `.assets` - checkout or populated secret files. -8. Restore the new tag in a clean checkout and run playback once more. - -Do not reuse the .NET assets tag in another language. Each language package owns -its own prefix, tag, recordings, and sanitizer configuration. - -## 9. Write samples and README - -Add executable, tested samples using the language repository's snippet system. -Include: - -- connection string, key credential, and Microsoft Entra ID authentication -- client access credential generation -- creating a room and user, adding and listing a room member, and cleanup -- listing built-in roles and permissions -- creating, assigning, listing, and deleting a custom role -- reading paged message history -- updating and deleting a message when supported -- handling the language's standard Azure service exception - -The package README must contain installation, prerequisites, authentication, -key concepts, short runnable examples, troubleshooting, and links to the package -samples. State clearly that the service client manages server-side Chat -resources while connected clients send real-time messages over WebSockets. - -Before merging, validate every README link: - -- Link only to package-manager pages that exist for the actual package name. -- Link only to identity packages and API references used by the sample code. -- Use relative sample links with exact path and filename casing. -- Use an official Azure Web PubSub documentation URL that resolves. -- Remove template links, placeholders, and references to samples or APIs that - are not included in the package. -- Run the language repository's link checker when one is available. - -Update the changelog/release notes with the added authentication methods, -resource operations, access generation, and built-in constants. - -## 10. Configure build and live-test pipelines - -Add the Chat package to the service area's package build/CI artifact list. Add a -live-test pipeline entry using the language repository's standard SDK test -template and configure: - -- service directory `webpubsub` -- the Chat package/test project -- Public Azure cloud support unless another cloud is verified -- the package directory as a test-resource directory -- the Chat test resource template. The C# reference is located at - `sdk/webpubsub/Azure.Messaging.WebPubSub.Chat/test-resources.bicep`; place the - target language's copy at the equivalent package test-resource location - expected by that repository's pipeline template -- secure injection of the endpoint and connection string -- test-proxy restore and playback in normal CI -- resource deployment, live execution, recording support, and cleanup in the - live-test pipeline - -Ensure service-level project discovery includes the Chat tests. If the service -repository supports conditional test exclusion, add a Chat-specific exclusion -property without excluding the tests by default. - -## 11. C# reference map - -Use these files in the .NET repository to compare behavior. Translate their -intent into the target language's conventions; do not translate C# mechanics -such as partial classes, linked compile items, or NUnit attributes literally. - -| Concern | C# reference | -| --- | --- | -| Client constructors, inner service client, access URI delegation | `sdk/webpubsub/Azure.Messaging.WebPubSub.Chat/src/WebPubSubChatServiceClient.cs` | -| Reverse proxy option | `sdk/webpubsub/Azure.Messaging.WebPubSub.Chat/src/WebPubSubChatServiceClientOptions.cs` | -| Access options | `sdk/webpubsub/Azure.Messaging.WebPubSub.Chat/src/GetClientAccessTokenOptions.cs` | -| Built-in constants | `sdk/webpubsub/Azure.Messaging.WebPubSub.Chat/src/ChatRoles.cs`, `RoomPermissions.cs`, and `UserPermissions.cs` | -| Shared key authentication and proxy behavior | `sdk/webpubsub/Azure.Messaging.WebPubSub/src/Shared/` | -| Client project dependencies/shared source | `sdk/webpubsub/Azure.Messaging.WebPubSub.Chat/src/Azure.Messaging.WebPubSub.Chat.csproj` | -| Unit tests | `sdk/webpubsub/Azure.Messaging.WebPubSub.Chat/tests/WebPubSubChatServiceClientTests.cs` and `ChatRolesAndPermissionsTests.cs` | -| Live tests and test environment | `sdk/webpubsub/Azure.Messaging.WebPubSub.Chat/tests/WebPubSubChatServiceClientLiveTests.cs` and `WebPubSubChatTestEnvironment.cs` | -| WebSocket/test-client helpers | `sdk/webpubsub/Azure.Messaging.WebPubSub.Chat/tests/ChatWebSocketHelper.cs` and `tests/tools/` | -| Samples | `sdk/webpubsub/Azure.Messaging.WebPubSub.Chat/tests/Samples/` | -| Resource deployment and recordings | `sdk/webpubsub/Azure.Messaging.WebPubSub.Chat/test-resources.bicep` and `assets.json` | -| Package live-test pipeline | `sdk/webpubsub/Azure.Messaging.WebPubSub.Chat/tests.yml` | -| Service build and test discovery | `sdk/webpubsub/ci.yml`, `sdk/webpubsub/tests.yml`, and `sdk/webpubsub/service.projects` | -| Package documentation and release notes | `sdk/webpubsub/Azure.Messaging.WebPubSub.Chat/README.md` and `CHANGELOG.md` | - -The C# working tree may contain work in progress. Treat handwritten source and -passing behavioral tests as authoritative. Do not copy stale API listings, -local `.env` content, ignored test behavior, or editor files. - -## 12. Completion checks - -The customization is complete only when all of the following pass: - -- regenerate the SDK and confirm handwritten customizations remain intact -- format, lint, build, and run the package's unit tests -- run recorded tests in playback mode from a clean environment -- run the live suite against a deployed resource -- push recordings and verify the new assets tag restores -- regenerate and review the public API surface -- build every README and sample snippet -- validate README and sample links -- run the language repository's package checks and API compatibility checks -- run or queue both package CI and the Web PubSub Chat live-test pipeline - -Review the final diff and confirm it contains no generated-file hand edits, -secrets, local `.env` values, `.assets` content, editor state, or unrelated -service changes. \ No newline at end of file diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/src/main/java/WebPubSubChatCustomization.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/src/main/java/WebPubSubChatCustomization.java index 67d3f85c2863b..0ae99dacc9c4a 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/src/main/java/WebPubSubChatCustomization.java +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/src/main/java/WebPubSubChatCustomization.java @@ -6,6 +6,9 @@ import com.azure.autorest.customization.PackageCustomization; import com.github.javaparser.StaticJavaParser; import com.github.javaparser.ast.body.MethodDeclaration; +import com.github.javaparser.ast.CompilationUnit; +import com.github.javaparser.ast.Modifier; +import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; import org.slf4j.Logger; /** Customizes the generated Azure Web PubSub Chat client library. */ @@ -33,6 +36,9 @@ public void customize(LibraryCustomization libraryCustomization, Logger logger) customizeTokenClient(chatPackage, "WebPubSubChatServiceClient"); customizeTokenClient(chatPackage, "WebPubSubChatServiceAsyncClient"); + libraryCustomization.getPackage(PACKAGE_NAME + ".models") + .getClass("MessageContent") + .customizeAst(WebPubSubChatCustomization::customizeMessageContent); customizeLifecycleDocumentation(libraryCustomization); removeTrailingJavadocWhitespace(libraryCustomization); @@ -106,6 +112,83 @@ static String correctLifecycleDocumentation(String source) { return source; } + static void customizeMessageContent(CompilationUnit ast) { + ClassOrInterfaceDeclaration model = ast.getClassByName("MessageContent") + .orElseThrow(() -> new IllegalStateException("MessageContent model not found.")); + ast.getImports() + .removeIf( + importDeclaration -> importDeclaration.getNameAsString().equals("com.azure.core.annotation.Fluent") + || importDeclaration.getNameAsString().equals("java.util.HashSet") + || importDeclaration.getNameAsString().equals("java.util.Set")); + ast.addImport("com.azure.core.annotation.Immutable"); + ast.addImport("com.azure.core.util.logging.ClientLogger"); + ast.addImport("java.util.Objects"); + model.getAnnotations().removeIf(annotation -> annotation.getNameAsString().equals("Fluent")); + if (!model.getAnnotationByName("Immutable").isPresent()) { + model.addMarkerAnnotation("Immutable"); + } + model.setJavadocComment("Message content containing exactly one of text or binary data.\n" + + "Use {@link #fromText(String)} or {@link #fromBinary(byte[])} to create content.\n" + + "The getter for the unselected representation returns {@code null}."); + model.getFieldByName("text").get().setFinal(true); + model.getFieldByName("binary").get().setFinal(true); + model.getFieldByName("updatedProperties").ifPresent(field -> field.remove()); + if (!model.getFieldByName("LOGGER").isPresent()) { + model.addFieldWithInitializer("ClientLogger", "LOGGER", + StaticJavaParser.parseExpression("new ClientLogger(MessageContent.class)"), Modifier.Keyword.PRIVATE, + Modifier.Keyword.STATIC, Modifier.Keyword.FINAL); + } + model.getConstructors().forEach(constructor -> constructor.remove()); + model.addMember(StaticJavaParser + .parseBodyDeclaration(String.join("\n", "private MessageContent(String text, byte[] binary) {", + " this.text = text;", " this.binary = CoreUtils.clone(binary);", "}"))); + model.getMethodsByName("setText").forEach(method -> method.remove()); + model.getMethodsByName("setBinary").forEach(method -> method.remove()); + model.getMethodsByName("fromText").forEach(method -> method.remove()); + model.getMethodsByName("fromBinary").forEach(method -> method.remove()); + model.addMember(StaticJavaParser.parseBodyDeclaration(String.join("\n", "/**", + " * Creates text message content.", " * @param text the text content, which may be empty.", + " * @return content containing the text and no binary data.", + " * @throws NullPointerException if text is null.", " */", + "public static MessageContent fromText(String text) {", + " return new MessageContent(Objects.requireNonNull(text, \"'text' cannot be null.\"), null);", "}"))); + model.addMember(StaticJavaParser.parseBodyDeclaration( + String.join("\n", "/**", " * Creates binary message content. The supplied array is defensively copied.", + " * @param binary the binary content, which may be empty.", + " * @return content containing the binary data and no text.", + " * @throws NullPointerException if binary is null.", " */", + "public static MessageContent fromBinary(byte[] binary) {", + " return new MessageContent(null, Objects.requireNonNull(binary, \"'binary' cannot be null.\"));", + "}"))); + model.getMethodsByName("toJsonMergePatch").forEach(method -> method.remove()); + model.getMethodsByName("toJson") + .get(0) + .setBody(StaticJavaParser.parseBlock(String.join("\n", "{", " jsonWriter.writeStartObject();", + " if (this.text != null) {", " jsonWriter.writeStringField(\"text\", this.text);", + " } else {", " jsonWriter.writeBinaryField(\"binary\", this.binary);", " }", + " return jsonWriter.writeEndObject();", "}"))); + model.getMethodsByName("fromJson") + .get(0) + .setBody(StaticJavaParser.parseBlock(String.join("\n", "{", " return jsonReader.readObject(reader -> {", + " String text = null;", " byte[] binary = null;", + " while (reader.nextToken() != JsonToken.END_OBJECT) {", + " String fieldName = reader.getFieldName();", " reader.nextToken();", + " if (\"text\".equals(fieldName)) {", " text = reader.getString();", + " } else if (\"binary\".equals(fieldName)) {", + " binary = reader.getBinary();", " } else {", + " reader.skipChildren();", " }", " }", + " if ((text == null) == (binary == null)) {", + " throw LOGGER.logExceptionAsError(new IllegalStateException(", + " \"Message content must contain exactly one non-null text or binary value.\"));", + " }", " return text != null ? fromText(text) : fromBinary(binary);", " });", "}"))); + model.getMethodsByName("fromJson") + .get(0) + .setJavadocComment(String.join("\n", "Reads text or binary message content from JSON.", + "@param jsonReader the JSON reader.", "@return the message content, or null if the JSON value is null.", + "@throws IllegalStateException if both representations are non-null or neither is non-null.", + "@throws IOException if an error occurs while reading the content.")); + } + private static void customizeTokenClient(PackageCustomization chatPackage, String className) { chatPackage.getClass(className).customizeAst(ast -> { ast.getImports() diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/src/test/java/WebPubSubChatMessageContentCustomizationTests.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/src/test/java/WebPubSubChatMessageContentCustomizationTests.java new file mode 100644 index 0000000000000..240f07aba9276 --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/src/test/java/WebPubSubChatMessageContentCustomizationTests.java @@ -0,0 +1,58 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +import com.github.javaparser.StaticJavaParser; +import com.github.javaparser.ast.CompilationUnit; +import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; +import org.junit.jupiter.api.Test; + +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Paths; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +public class WebPubSubChatMessageContentCustomizationTests { + @Test + public void customizesGeneratedModelAndIsIdempotent() { + CompilationUnit ast = StaticJavaParser + .parse(String.join("\n", "import com.azure.core.annotation.Fluent;", "import java.util.Set;", + "import java.util.HashSet;", "@Fluent public final class MessageContent {", " private String text;", + " private byte[] binary;", " private final Set updatedProperties = new HashSet<>();", + " public MessageContent() {}", " public MessageContent setText(String text) { return this; }", + " public MessageContent setBinary(byte[] binary) { return this; }", + " public JsonWriter toJson(JsonWriter writer) { return writer; }", + " private JsonWriter toJsonMergePatch(JsonWriter writer) { return writer; }", + " public static MessageContent fromJson(JsonReader reader) { return null; }", "}")); + + WebPubSubChatCustomization.customizeMessageContent(ast); + ClassOrInterfaceDeclaration model = ast.getClassByName("MessageContent").get(); + assertEquals(1, model.getConstructors().size()); + assertTrue(model.getConstructors().get(0).isPrivate()); + assertTrue(model.getMethodsByName("setText").isEmpty()); + assertTrue(model.getMethodsByName("setBinary").isEmpty()); + assertTrue(model.getMethodsByName("fromText").get(0).isStatic()); + assertTrue(model.getMethodsByName("fromBinary").get(0).isStatic()); + assertTrue(model.getFieldByName("text").get().isFinal()); + assertTrue(model.getFieldByName("binary").get().isFinal()); + assertFalse(model.getFieldByName("updatedProperties").isPresent()); + assertTrue(model.getAnnotationByName("Immutable").isPresent()); + + String customized = ast.toString(); + WebPubSubChatCustomization.customizeMessageContent(ast); + assertEquals(customized, ast.toString()); + } + + @Test + public void checkedInModelIncludesCustomization() throws IOException { + String source = new String(Files.readAllBytes(Paths.get("..", "src", "main", "java", "com", "azure", + "messaging", "webpubsub", "chat", "models", "MessageContent.java")), StandardCharsets.UTF_8); + CompilationUnit expected = StaticJavaParser.parse(source); + CompilationUnit actual = expected.clone(); + WebPubSubChatCustomization.customizeMessageContent(actual); + assertEquals(expected.toString(), actual.toString()); + } +} diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/MessageContent.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/MessageContent.java index e5ee9ed3fa15e..c93a20795f652 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/MessageContent.java +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/MessageContent.java @@ -3,7 +3,6 @@ // Code generated by Microsoft (R) TypeSpec Code Generator. package com.azure.messaging.webpubsub.chat.models; -import com.azure.core.annotation.Fluent; import com.azure.core.annotation.Generated; import com.azure.core.util.CoreUtils; import com.azure.json.JsonReader; @@ -12,32 +11,29 @@ import com.azure.json.JsonWriter; import com.azure.messaging.webpubsub.chat.implementation.JsonMergePatchHelper; import java.io.IOException; -import java.util.HashSet; -import java.util.Set; +import com.azure.core.annotation.Immutable; +import com.azure.core.util.logging.ClientLogger; +import java.util.Objects; /** - * Message content body. + * Message content containing exactly one of text or binary data. + * Use {@link #fromText(String)} or {@link #fromBinary(byte[])} to create content. + * The getter for the unselected representation returns {@code null}. */ -@Fluent +@Immutable public final class MessageContent implements JsonSerializable { /* * Text content. */ @Generated - private String text; + private final String text; /* * Binary content (base64 encoded). */ @Generated - private byte[] binary; - - /** - * Stores updated model property, the value is property name, not serialized name. - */ - @Generated - private final Set updatedProperties = new HashSet<>(); + private final byte[] binary; @Generated private boolean jsonMergePatch; @@ -63,13 +59,6 @@ public boolean isJsonMergePatch(MessageContent model) { }); } - /** - * Creates an instance of MessageContent class. - */ - @Generated - public MessageContent() { - } - /** * Get the text property: Text content. * @@ -80,19 +69,6 @@ public String getText() { return this.text; } - /** - * Set the text property: Text content. - * - * @param text the text value to set. - * @return the MessageContent object itself. - */ - @Generated - public MessageContent setText(String text) { - this.text = text; - this.updatedProperties.add("text"); - return this; - } - /** * Get the binary property: Binary content (base64 encoded). * @@ -103,79 +79,76 @@ public byte[] getBinary() { return CoreUtils.clone(this.binary); } - /** - * Set the binary property: Binary content (base64 encoded). - * - * @param binary the binary value to set. - * @return the MessageContent object itself. - */ - @Generated - public MessageContent setBinary(byte[] binary) { - this.binary = CoreUtils.clone(binary); - this.updatedProperties.add("binary"); - return this; - } - /** * {@inheritDoc} */ @Generated @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - if (jsonMergePatch) { - return toJsonMergePatch(jsonWriter); - } else { - jsonWriter.writeStartObject(); + jsonWriter.writeStartObject(); + if (this.text != null) { jsonWriter.writeStringField("text", this.text); + } else { jsonWriter.writeBinaryField("binary", this.binary); - return jsonWriter.writeEndObject(); - } - } - - @Generated - private JsonWriter toJsonMergePatch(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - if (updatedProperties.contains("text")) { - if (this.text == null) { - jsonWriter.writeNullField("text"); - } else { - jsonWriter.writeStringField("text", this.text); - } - } - if (updatedProperties.contains("binary")) { - if (this.binary == null) { - jsonWriter.writeNullField("binary"); - } else { - jsonWriter.writeBinaryField("binary", this.binary); - } } return jsonWriter.writeEndObject(); } /** - * Reads an instance of MessageContent from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of MessageContent if the JsonReader was pointing to an instance of it, or null if it was - * pointing to JSON null. - * @throws IOException If an error occurs while reading the MessageContent. + * Reads text or binary message content from JSON. + * @param jsonReader the JSON reader. + * @return the message content, or null if the JSON value is null. + * @throws IllegalStateException if both representations are non-null or neither is non-null. + * @throws IOException if an error occurs while reading the content. */ @Generated public static MessageContent fromJson(JsonReader jsonReader) throws IOException { return jsonReader.readObject(reader -> { - MessageContent deserializedMessageContent = new MessageContent(); + String text = null; + byte[] binary = null; while (reader.nextToken() != JsonToken.END_OBJECT) { String fieldName = reader.getFieldName(); reader.nextToken(); if ("text".equals(fieldName)) { - deserializedMessageContent.text = reader.getString(); + text = reader.getString(); } else if ("binary".equals(fieldName)) { - deserializedMessageContent.binary = reader.getBinary(); + binary = reader.getBinary(); } else { reader.skipChildren(); } } - return deserializedMessageContent; + if ((text == null) == (binary == null)) { + throw LOGGER.logExceptionAsError(new IllegalStateException( + "Message content must contain exactly one non-null text or binary value.")); + } + return text != null ? fromText(text) : fromBinary(binary); }); } + + private static final ClientLogger LOGGER = new ClientLogger(MessageContent.class); + + private MessageContent(String text, byte[] binary) { + this.text = text; + this.binary = CoreUtils.clone(binary); + } + + /** + * Creates text message content. + * @param text the text content, which may be empty. + * @return content containing the text and no binary data. + * @throws NullPointerException if text is null. + */ + public static MessageContent fromText(String text) { + return new MessageContent(Objects.requireNonNull(text, "'text' cannot be null."), null); + } + + /** + * Creates binary message content. The supplied array is defensively copied. + * @param binary the binary content, which may be empty. + * @return content containing the binary data and no text. + * @throws NullPointerException if binary is null. + */ + public static MessageContent fromBinary(byte[] binary) { + return new MessageContent(null, Objects.requireNonNull(binary, "'binary' cannot be null.")); + } } diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/samples/java/com/azure/messaging/webpubsub/chat/WebPubSubChatSamples.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/samples/java/com/azure/messaging/webpubsub/chat/WebPubSubChatSamples.java index d995500b6cda7..ecc433414f351 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/samples/java/com/azure/messaging/webpubsub/chat/WebPubSubChatSamples.java +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/samples/java/com/azure/messaging/webpubsub/chat/WebPubSubChatSamples.java @@ -7,6 +7,7 @@ import com.azure.identity.DefaultAzureCredentialBuilder; import com.azure.messaging.webpubsub.chat.models.BuiltInChatRoles; import com.azure.messaging.webpubsub.chat.models.ChatPermission; +import com.azure.messaging.webpubsub.chat.models.ChatMessage; import com.azure.messaging.webpubsub.chat.models.ChatRole; import com.azure.messaging.webpubsub.chat.models.ChatRoom; import com.azure.messaging.webpubsub.chat.models.ChatRoomMember; @@ -14,6 +15,7 @@ import com.azure.messaging.webpubsub.chat.models.ChatTopicState; import com.azure.messaging.webpubsub.chat.models.GetClientAccessTokenOptions; import com.azure.messaging.webpubsub.chat.models.HumanChatUser; +import com.azure.messaging.webpubsub.chat.models.MessageContent; import com.azure.messaging.webpubsub.chat.models.WebPubSubClientAccessToken; import java.time.Duration; @@ -21,6 +23,16 @@ /** Code snippets used by the package README. */ public final class WebPubSubChatSamples { + /** Updates an existing message with text or binary content. */ + public void updateMessage(WebPubSubChatServiceClient client, String conversationId, String messageId) { + // BEGIN: readme-sample-updateChatMessageContent + client.updateMessage(conversationId, messageId, + new ChatMessage().setContent(MessageContent.fromText("Updated message"))); + client.updateMessage(conversationId, messageId, + new ChatMessage().setContent(MessageContent.fromBinary(new byte[] { 1, 2, 3 }))); + // END: readme-sample-updateChatMessageContent + } + /** Creates a client from a connection string. */ public void createClientWithConnectionString() { // BEGIN: readme-sample-createChatClientWithConnectionString diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/ChatServiceAsyncClientLiveTests.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/ChatServiceAsyncClientLiveTests.java index 1d87b738e8c33..b52481df6b0ed 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/ChatServiceAsyncClientLiveTests.java +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/ChatServiceAsyncClientLiveTests.java @@ -159,7 +159,7 @@ public void canListUpdateAndDeleteMessages() { = asyncClient .updateMessage(conversationId, messageId, new ChatMessage().setCreatedBy(userId) - .setContent(new MessageContent().setText(messageText + " updated"))) + .setContent(MessageContent.fromText(messageText + " updated"))) .block(); assertEquals(messageText + " updated", updatedText.getContent().getText()); @@ -167,7 +167,7 @@ public void canListUpdateAndDeleteMessages() { ChatMessage updatedBinary = asyncClient .updateMessage(conversationId, messageId, - new ChatMessage().setCreatedBy(userId).setContent(new MessageContent().setBinary(binary))) + new ChatMessage().setCreatedBy(userId).setContent(MessageContent.fromBinary(binary))) .block(); assertArrayEquals(binary, updatedBinary.getContent().getBinary()); asyncClient.deleteMessage(conversationId, messageId).block(); diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/ChatServiceClientLiveTests.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/ChatServiceClientLiveTests.java index 960bd7a5ef75f..eb034175b7713 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/ChatServiceClientLiveTests.java +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/ChatServiceClientLiveTests.java @@ -155,14 +155,13 @@ public void canListUpdateAndDeleteMessages() { .orElseThrow(() -> new AssertionError("The seeded Chat message was not found.")); messageId = createdMessage.getId(); - ChatMessage updatedText - = client.updateMessage(conversationId, messageId, new ChatMessage().setCreatedBy(userId) - .setContent(new MessageContent().setText(messageText + " updated"))); + ChatMessage updatedText = client.updateMessage(conversationId, messageId, + new ChatMessage().setCreatedBy(userId).setContent(MessageContent.fromText(messageText + " updated"))); assertEquals(messageText + " updated", updatedText.getContent().getText()); byte[] binary = new byte[] { 0, 1, 2, (byte) 254, (byte) 255 }; ChatMessage updatedBinary = client.updateMessage(conversationId, messageId, - new ChatMessage().setCreatedBy(userId).setContent(new MessageContent().setBinary(binary))); + new ChatMessage().setCreatedBy(userId).setContent(MessageContent.fromBinary(binary))); assertArrayEquals(binary, updatedBinary.getContent().getBinary()); client.deleteMessage(conversationId, messageId); } finally { diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/MessageContentTests.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/MessageContentTests.java new file mode 100644 index 0000000000000..6f546dfb75a62 --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/MessageContentTests.java @@ -0,0 +1,177 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.messaging.webpubsub.chat; + +import com.azure.core.http.HttpHeaderName; +import com.azure.core.http.HttpHeaders; +import com.azure.core.http.HttpRequest; +import com.azure.core.test.http.MockHttpResponse; +import com.azure.core.test.utils.MockTokenCredential; +import com.azure.json.JsonProviders; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonWriter; +import com.azure.messaging.webpubsub.chat.implementation.JsonMergePatchHelper; +import com.azure.messaging.webpubsub.chat.models.ChatMessage; +import com.azure.messaging.webpubsub.chat.models.MessageContent; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; +import reactor.core.publisher.Mono; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.util.concurrent.atomic.AtomicReference; + +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; + +public class MessageContentTests { + @Test + public void factoriesRequireSelectedValue() { + assertThrows(NullPointerException.class, () -> MessageContent.fromText(null)); + assertThrows(NullPointerException.class, () -> MessageContent.fromBinary(null)); + } + + @Test + public void binaryIsDefensivelyCopied() { + byte[] bytes = { 0, 1, (byte) 255 }; + MessageContent content = MessageContent.fromBinary(bytes); + bytes[0] = 42; + byte[] returned = content.getBinary(); + returned[1] = 42; + assertArrayEquals(new byte[] { 0, 1, (byte) 255 }, content.getBinary()); + assertNull(content.getText()); + } + + @ParameterizedTest + @ValueSource(strings = { "", "hello", "line\n\"quoted\"" }) + public void textRoundTrips(String text) throws IOException { + MessageContent content = deserialize(serialize(MessageContent.fromText(text))); + assertEquals(text, content.getText()); + assertNull(content.getBinary()); + } + + @ParameterizedTest + @ValueSource(booleans = { false, true }) + public void binaryRoundTrips(boolean empty) throws IOException { + byte[] bytes = empty ? new byte[0] : new byte[] { 0, 1, (byte) 254, (byte) 255 }; + MessageContent content = deserialize(serialize(MessageContent.fromBinary(bytes))); + assertArrayEquals(bytes, content.getBinary()); + assertNull(content.getText()); + } + + @ParameterizedTest + @ValueSource( + strings = { + "{\"text\":\"hello\"}", + "{\"binary\":null,\"text\":\"hello\",\"unknown\":{\"nested\":[1,2]}}", + "{\"text\":\"hello\",\"binary\":null}" }) + public void deserializesTextWithUnusedNullAndUnknownFields(String json) throws IOException { + MessageContent content = deserialize(json); + assertEquals("hello", content.getText()); + assertNull(content.getBinary()); + assertEquals("{\"text\":\"hello\"}", serialize(content)); + } + + @ParameterizedTest + @ValueSource( + strings = { + "{\"binary\":\"AQID\"}", + "{\"text\":null,\"binary\":\"AQID\"}", + "{\"binary\":\"AQID\",\"text\":null,\"unknown\":[{\"value\":1}]}" }) + public void deserializesBinaryWithUnusedNullAndUnknownFields(String json) throws IOException { + MessageContent content = deserialize(json); + assertArrayEquals(new byte[] { 1, 2, 3 }, content.getBinary()); + assertNull(content.getText()); + assertEquals("{\"binary\":\"AQID\"}", serialize(content)); + } + + @ParameterizedTest + @ValueSource( + strings = { + "{}", + "{\"text\":null}", + "{\"binary\":null}", + "{\"text\":null,\"binary\":null}", + "{\"text\":\"hello\",\"binary\":\"AQID\"}", + "{\"binary\":\"AQID\",\"text\":\"hello\"}", + "{\"unknown\":true}" }) + public void rejectsContentWithoutExactlyOneValue(String json) { + assertThrows(IllegalStateException.class, () -> deserialize(json)); + } + + @Test + public void jsonNullRemainsNull() throws IOException { + assertNull(deserialize("null")); + } + + @ParameterizedTest + @ValueSource(strings = { "{\"text\":\"hello\"}", "{\"binary\":\"AQID\"}" }) + public void factoryAndDeserializedContentHaveIdenticalPatchBodies(String json) throws IOException { + MessageContent deserialized = deserialize(json); + MessageContent created = deserialized.getText() != null + ? MessageContent.fromText(deserialized.getText()) + : MessageContent.fromBinary(deserialized.getBinary()); + assertEquals("{\"content\":" + json + "}", serializePatch(new ChatMessage().setContent(created))); + assertEquals("{\"content\":" + json + "}", serializePatch(new ChatMessage().setContent(deserialized))); + assertFalse(JsonMergePatchHelper.getMessageContentAccessor().isJsonMergePatch(deserialized)); + assertEquals(json, serialize(deserialized)); + } + + @Test + public void patchPreservesOmittedAndExplicitNullContent() throws IOException { + assertEquals("{}", serializePatch(new ChatMessage())); + assertEquals("{\"content\":null}", serializePatch(new ChatMessage().setContent(null))); + } + + @ParameterizedTest + @ValueSource(booleans = { false, true }) + public void syncAndAsyncUpdatesSendOnlySelectedContent(boolean async) throws IOException { + AtomicReference sentRequest = new AtomicReference<>(); + String response = "{\"content\":{\"binary\":\"AQID\"}}"; + WebPubSubChatServiceClientBuilder builder + = new WebPubSubChatServiceClientBuilder().endpoint("https://example.webpubsub.azure.com") + .hub("chat") + .credential(new MockTokenCredential()) + .httpClient(request -> { + sentRequest.set(request); + return Mono.just(new MockHttpResponse(request, 200, + new HttpHeaders().set(HttpHeaderName.CONTENT_TYPE, "application/json"), + response.getBytes(StandardCharsets.UTF_8))); + }); + ChatMessage update = new ChatMessage().setContent(deserialize("{\"binary\":\"AQID\"}")); + ChatMessage result = async + ? builder.buildAsyncClient().updateMessage("c.room.default", "1", update).block() + : builder.buildClient().updateMessage("c.room.default", "1", update); + assertArrayEquals(new byte[] { 1, 2, 3 }, result.getContent().getBinary()); + assertEquals("{\"content\":{\"binary\":\"AQID\"}}", sentRequest.get().getBodyAsBinaryData().toString()); + assertEquals("application/merge-patch+json", + sentRequest.get().getHeaders().getValue(HttpHeaderName.CONTENT_TYPE)); + } + + private static MessageContent deserialize(String json) throws IOException { + try (JsonReader reader = JsonProviders.createReader(json)) { + return MessageContent.fromJson(reader); + } + } + + private static String serializePatch(ChatMessage message) throws IOException { + JsonMergePatchHelper.getChatMessageAccessor().prepareModelForJsonMergePatch(message, true); + return serialize(message); + } + + private static String serialize(JsonSerializable value) throws IOException { + ByteArrayOutputStream output = new ByteArrayOutputStream(); + try (JsonWriter writer = JsonProviders.createWriter(output)) { + value.toJson(writer); + writer.flush(); + } + return new String(output.toByteArray(), StandardCharsets.UTF_8); + } +} From 2b545f4e8f0c4560eca628159db2f512168561a2 Mon Sep 17 00:00:00 2001 From: Zitong Yang Date: Tue, 27 Oct 2026 17:17:02 +1100 Subject: [PATCH 06/18] Fix Web PubSub Chat regeneration formatting drift Align MessageContent imports and Javadoc with generated output and preserve Javadoc spacing in the customization. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .../src/main/java/WebPubSubChatCustomization.java | 6 +++--- .../messaging/webpubsub/chat/models/MessageContent.java | 7 +++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/src/main/java/WebPubSubChatCustomization.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/src/main/java/WebPubSubChatCustomization.java index 0ae99dacc9c4a..9c8d2b9f79036 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/src/main/java/WebPubSubChatCustomization.java +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/src/main/java/WebPubSubChatCustomization.java @@ -147,14 +147,14 @@ static void customizeMessageContent(CompilationUnit ast) { model.getMethodsByName("fromText").forEach(method -> method.remove()); model.getMethodsByName("fromBinary").forEach(method -> method.remove()); model.addMember(StaticJavaParser.parseBodyDeclaration(String.join("\n", "/**", - " * Creates text message content.", " * @param text the text content, which may be empty.", + " * Creates text message content.", " *", " * @param text the text content, which may be empty.", " * @return content containing the text and no binary data.", " * @throws NullPointerException if text is null.", " */", "public static MessageContent fromText(String text) {", " return new MessageContent(Objects.requireNonNull(text, \"'text' cannot be null.\"), null);", "}"))); model.addMember(StaticJavaParser.parseBodyDeclaration( String.join("\n", "/**", " * Creates binary message content. The supplied array is defensively copied.", - " * @param binary the binary content, which may be empty.", + " *", " * @param binary the binary content, which may be empty.", " * @return content containing the binary data and no text.", " * @throws NullPointerException if binary is null.", " */", "public static MessageContent fromBinary(byte[] binary) {", @@ -183,7 +183,7 @@ static void customizeMessageContent(CompilationUnit ast) { " }", " return text != null ? fromText(text) : fromBinary(binary);", " });", "}"))); model.getMethodsByName("fromJson") .get(0) - .setJavadocComment(String.join("\n", "Reads text or binary message content from JSON.", + .setJavadocComment(String.join("\n", "Reads text or binary message content from JSON.", "", "@param jsonReader the JSON reader.", "@return the message content, or null if the JSON value is null.", "@throws IllegalStateException if both representations are non-null or neither is non-null.", "@throws IOException if an error occurs while reading the content.")); diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/MessageContent.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/MessageContent.java index c93a20795f652..d3967e7968a26 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/MessageContent.java +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/MessageContent.java @@ -4,15 +4,15 @@ package com.azure.messaging.webpubsub.chat.models; import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; import com.azure.core.util.CoreUtils; +import com.azure.core.util.logging.ClientLogger; import com.azure.json.JsonReader; import com.azure.json.JsonSerializable; import com.azure.json.JsonToken; import com.azure.json.JsonWriter; import com.azure.messaging.webpubsub.chat.implementation.JsonMergePatchHelper; import java.io.IOException; -import com.azure.core.annotation.Immutable; -import com.azure.core.util.logging.ClientLogger; import java.util.Objects; /** @@ -96,6 +96,7 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads text or binary message content from JSON. + * * @param jsonReader the JSON reader. * @return the message content, or null if the JSON value is null. * @throws IllegalStateException if both representations are non-null or neither is non-null. @@ -134,6 +135,7 @@ private MessageContent(String text, byte[] binary) { /** * Creates text message content. + * * @param text the text content, which may be empty. * @return content containing the text and no binary data. * @throws NullPointerException if text is null. @@ -144,6 +146,7 @@ public static MessageContent fromText(String text) { /** * Creates binary message content. The supplied array is defensively copied. + * * @param binary the binary content, which may be empty. * @return content containing the binary data and no text. * @throws NullPointerException if binary is null. From fc01f87426d15dd65a73ae7a41b8f4826fd9c993 Mon Sep 17 00:00:00 2001 From: Zitong Yang Date: Tue, 27 Oct 2026 18:13:35 +1100 Subject: [PATCH 07/18] Simplify MessageContent customization with partial update Preserve handwritten fields and serialization methods through partial update instead of duplicating their implementations in AST customization. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .../main/java/WebPubSubChatCustomization.java | 57 +------------------ ...bChatMessageContentCustomizationTests.java | 38 ++++++++----- .../webpubsub/chat/models/MessageContent.java | 4 -- 3 files changed, 26 insertions(+), 73 deletions(-) diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/src/main/java/WebPubSubChatCustomization.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/src/main/java/WebPubSubChatCustomization.java index 9c8d2b9f79036..dc1753044eb98 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/src/main/java/WebPubSubChatCustomization.java +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/src/main/java/WebPubSubChatCustomization.java @@ -7,7 +7,6 @@ import com.github.javaparser.StaticJavaParser; import com.github.javaparser.ast.body.MethodDeclaration; import com.github.javaparser.ast.CompilationUnit; -import com.github.javaparser.ast.Modifier; import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; import org.slf4j.Logger; @@ -113,6 +112,7 @@ static String correctLifecycleDocumentation(String source) { } static void customizeMessageContent(CompilationUnit ast) { + // Partial update preserves handwritten members without @Generated, but regenerates removed setters. ClassOrInterfaceDeclaration model = ast.getClassByName("MessageContent") .orElseThrow(() -> new IllegalStateException("MessageContent model not found.")); ast.getImports() @@ -121,8 +121,6 @@ static void customizeMessageContent(CompilationUnit ast) { || importDeclaration.getNameAsString().equals("java.util.HashSet") || importDeclaration.getNameAsString().equals("java.util.Set")); ast.addImport("com.azure.core.annotation.Immutable"); - ast.addImport("com.azure.core.util.logging.ClientLogger"); - ast.addImport("java.util.Objects"); model.getAnnotations().removeIf(annotation -> annotation.getNameAsString().equals("Fluent")); if (!model.getAnnotationByName("Immutable").isPresent()) { model.addMarkerAnnotation("Immutable"); @@ -130,63 +128,10 @@ static void customizeMessageContent(CompilationUnit ast) { model.setJavadocComment("Message content containing exactly one of text or binary data.\n" + "Use {@link #fromText(String)} or {@link #fromBinary(byte[])} to create content.\n" + "The getter for the unselected representation returns {@code null}."); - model.getFieldByName("text").get().setFinal(true); - model.getFieldByName("binary").get().setFinal(true); model.getFieldByName("updatedProperties").ifPresent(field -> field.remove()); - if (!model.getFieldByName("LOGGER").isPresent()) { - model.addFieldWithInitializer("ClientLogger", "LOGGER", - StaticJavaParser.parseExpression("new ClientLogger(MessageContent.class)"), Modifier.Keyword.PRIVATE, - Modifier.Keyword.STATIC, Modifier.Keyword.FINAL); - } - model.getConstructors().forEach(constructor -> constructor.remove()); - model.addMember(StaticJavaParser - .parseBodyDeclaration(String.join("\n", "private MessageContent(String text, byte[] binary) {", - " this.text = text;", " this.binary = CoreUtils.clone(binary);", "}"))); model.getMethodsByName("setText").forEach(method -> method.remove()); model.getMethodsByName("setBinary").forEach(method -> method.remove()); - model.getMethodsByName("fromText").forEach(method -> method.remove()); - model.getMethodsByName("fromBinary").forEach(method -> method.remove()); - model.addMember(StaticJavaParser.parseBodyDeclaration(String.join("\n", "/**", - " * Creates text message content.", " *", " * @param text the text content, which may be empty.", - " * @return content containing the text and no binary data.", - " * @throws NullPointerException if text is null.", " */", - "public static MessageContent fromText(String text) {", - " return new MessageContent(Objects.requireNonNull(text, \"'text' cannot be null.\"), null);", "}"))); - model.addMember(StaticJavaParser.parseBodyDeclaration( - String.join("\n", "/**", " * Creates binary message content. The supplied array is defensively copied.", - " *", " * @param binary the binary content, which may be empty.", - " * @return content containing the binary data and no text.", - " * @throws NullPointerException if binary is null.", " */", - "public static MessageContent fromBinary(byte[] binary) {", - " return new MessageContent(null, Objects.requireNonNull(binary, \"'binary' cannot be null.\"));", - "}"))); model.getMethodsByName("toJsonMergePatch").forEach(method -> method.remove()); - model.getMethodsByName("toJson") - .get(0) - .setBody(StaticJavaParser.parseBlock(String.join("\n", "{", " jsonWriter.writeStartObject();", - " if (this.text != null) {", " jsonWriter.writeStringField(\"text\", this.text);", - " } else {", " jsonWriter.writeBinaryField(\"binary\", this.binary);", " }", - " return jsonWriter.writeEndObject();", "}"))); - model.getMethodsByName("fromJson") - .get(0) - .setBody(StaticJavaParser.parseBlock(String.join("\n", "{", " return jsonReader.readObject(reader -> {", - " String text = null;", " byte[] binary = null;", - " while (reader.nextToken() != JsonToken.END_OBJECT) {", - " String fieldName = reader.getFieldName();", " reader.nextToken();", - " if (\"text\".equals(fieldName)) {", " text = reader.getString();", - " } else if (\"binary\".equals(fieldName)) {", - " binary = reader.getBinary();", " } else {", - " reader.skipChildren();", " }", " }", - " if ((text == null) == (binary == null)) {", - " throw LOGGER.logExceptionAsError(new IllegalStateException(", - " \"Message content must contain exactly one non-null text or binary value.\"));", - " }", " return text != null ? fromText(text) : fromBinary(binary);", " });", "}"))); - model.getMethodsByName("fromJson") - .get(0) - .setJavadocComment(String.join("\n", "Reads text or binary message content from JSON.", "", - "@param jsonReader the JSON reader.", "@return the message content, or null if the JSON value is null.", - "@throws IllegalStateException if both representations are non-null or neither is non-null.", - "@throws IOException if an error occurs while reading the content.")); } private static void customizeTokenClient(PackageCustomization chatPackage, String className) { diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/src/test/java/WebPubSubChatMessageContentCustomizationTests.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/src/test/java/WebPubSubChatMessageContentCustomizationTests.java index 240f07aba9276..c3ffb42aa3dce 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/src/test/java/WebPubSubChatMessageContentCustomizationTests.java +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/src/test/java/WebPubSubChatMessageContentCustomizationTests.java @@ -17,16 +17,17 @@ public class WebPubSubChatMessageContentCustomizationTests { @Test - public void customizesGeneratedModelAndIsIdempotent() { - CompilationUnit ast = StaticJavaParser - .parse(String.join("\n", "import com.azure.core.annotation.Fluent;", "import java.util.Set;", - "import java.util.HashSet;", "@Fluent public final class MessageContent {", " private String text;", - " private byte[] binary;", " private final Set updatedProperties = new HashSet<>();", - " public MessageContent() {}", " public MessageContent setText(String text) { return this; }", - " public MessageContent setBinary(byte[] binary) { return this; }", - " public JsonWriter toJson(JsonWriter writer) { return writer; }", - " private JsonWriter toJsonMergePatch(JsonWriter writer) { return writer; }", - " public static MessageContent fromJson(JsonReader reader) { return null; }", "}")); + public void removesRegeneratedMutableMembersAndIsIdempotent() throws IOException { + CompilationUnit ast = readModel(); + ClassOrInterfaceDeclaration original = ast.getClassByName("MessageContent").get(); + original.addMember(StaticJavaParser.parseBodyDeclaration( + "private final java.util.Set updatedProperties = new java.util.HashSet<>();")); + original.addMember( + StaticJavaParser.parseBodyDeclaration("public MessageContent setText(String text) { return this; }")); + original.addMember( + StaticJavaParser.parseBodyDeclaration("public MessageContent setBinary(byte[] binary) { return this; }")); + original.addMember(StaticJavaParser + .parseBodyDeclaration("private JsonWriter toJsonMergePatch(JsonWriter writer) { return writer; }")); WebPubSubChatCustomization.customizeMessageContent(ast); ClassOrInterfaceDeclaration model = ast.getClassByName("MessageContent").get(); @@ -48,11 +49,22 @@ public void customizesGeneratedModelAndIsIdempotent() { @Test public void checkedInModelIncludesCustomization() throws IOException { - String source = new String(Files.readAllBytes(Paths.get("..", "src", "main", "java", "com", "azure", - "messaging", "webpubsub", "chat", "models", "MessageContent.java")), StandardCharsets.UTF_8); - CompilationUnit expected = StaticJavaParser.parse(source); + CompilationUnit expected = readModel(); + ClassOrInterfaceDeclaration model = expected.getClassByName("MessageContent").get(); + for (String name : new String[] { "toJson", "fromJson", "fromText", "fromBinary" }) { + assertFalse(model.getMethodsByName(name).get(0).getAnnotationByName("Generated").isPresent()); + } + for (String name : new String[] { "text", "binary" }) { + assertFalse(model.getFieldByName(name).get().getAnnotationByName("Generated").isPresent()); + } CompilationUnit actual = expected.clone(); WebPubSubChatCustomization.customizeMessageContent(actual); assertEquals(expected.toString(), actual.toString()); } + + private static CompilationUnit readModel() throws IOException { + String source = new String(Files.readAllBytes(Paths.get("..", "src", "main", "java", "com", "azure", + "messaging", "webpubsub", "chat", "models", "MessageContent.java")), StandardCharsets.UTF_8); + return StaticJavaParser.parse(source); + } } diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/MessageContent.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/MessageContent.java index d3967e7968a26..d71498aaa3da3 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/MessageContent.java +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/MessageContent.java @@ -26,13 +26,11 @@ public final class MessageContent implements JsonSerializable { /* * Text content. */ - @Generated private final String text; /* * Binary content (base64 encoded). */ - @Generated private final byte[] binary; @Generated @@ -82,7 +80,6 @@ public byte[] getBinary() { /** * {@inheritDoc} */ - @Generated @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); @@ -102,7 +99,6 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { * @throws IllegalStateException if both representations are non-null or neither is non-null. * @throws IOException if an error occurs while reading the content. */ - @Generated public static MessageContent fromJson(JsonReader jsonReader) throws IOException { return jsonReader.readObject(reader -> { String text = null; From 0b679988dfa31f712128c9ae295b5e3669ec9f74 Mon Sep 17 00:00:00 2001 From: Zitong Yang Date: Tue, 27 Oct 2026 20:39:46 -0700 Subject: [PATCH 08/18] Address Web PubSub Chat review feedback Share new sync/async scenarios, preserve isolated Chat test resources, and clarify topic creation state and README guidance. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .../azure-messaging-webpubsub-chat/README.md | 27 ++- .../assets.json | 2 +- .../main/java/WebPubSubChatCustomization.java | 14 +- .../java/WebPubSubChatDocumentationTests.java | 24 +- .../chat/WebPubSubChatServiceAsyncClient.java | 9 + .../chat/WebPubSubChatServiceClient.java | 9 + .../WebPubSubChatServiceClientImpl.java | 6 + .../webpubsub/chat/models/ChatTopic.java | 3 +- ...ChatServiceAugustAsyncClientLiveTests.java | 172 --------------- .../ChatServiceAugustClientLiveTests.java | 156 ------------- .../chat/ChatServiceClientLiveTests.java | 205 ++++++++++++++++++ ...ebPubSubChatServiceClientBuilderTests.java | 11 - .../test-resources.bicep | 8 +- sdk/webpubsub/tests.yml | 6 - 14 files changed, 292 insertions(+), 360 deletions(-) delete mode 100644 sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/ChatServiceAugustAsyncClientLiveTests.java delete mode 100644 sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/ChatServiceAugustClientLiveTests.java diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/README.md b/sdk/webpubsub/azure-messaging-webpubsub-chat/README.md index 3a5020a6ba255..c02724239fb46 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/README.md +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/README.md @@ -25,9 +25,6 @@ Use this client library in an application server to: ### Install the package -The following dependency shows the current development version. It has not been -released to Maven Central; build it locally when evaluating the new API. - [//]: # ({x-version-update-start;com.azure:azure-messaging-webpubsub-chat;current}) ```xml @@ -78,6 +75,7 @@ WebPubSubChatServiceClient client = new WebPubSubChatServiceClientBuilder() For more information, see [Authenticate Azure-hosted Java applications][azure_identity_auth] and [Microsoft Entra authorization for Azure Web PubSub][entra_authorization]. ## Key concepts + ### Hub A hub is a logical collection of WebSocket connections. A chat hub adds built-in rooms, member management, message persistence, and chat-specific APIs. @@ -115,6 +113,26 @@ renamed, archived, and soft deleted independently of the room's default conversa ## Examples +- [Generate a client access token](#generate-a-client-access-token) +- [Work with built-in values](#work-with-built-in-values) +- [Create a custom role](#create-a-custom-role) +- [List roles](#list-roles) +- [Delete a custom role](#delete-a-custom-role) +- [Create a user](#create-a-user) +- [Create a room](#create-a-room) +- [Add a room member](#add-a-room-member) +- [List rooms](#list-rooms) +- [List users](#list-users) +- [List rooms for a user](#list-rooms-for-a-user) +- [Create a topic](#create-a-topic) +- [Get a topic](#get-a-topic) +- [Update a topic](#update-a-topic) +- [List topics](#list-topics) +- [Soft delete a topic](#soft-delete-a-topic) +- [List persisted messages](#list-persisted-messages) +- [Update message content](#update-message-content) +- [Use the asynchronous client](#use-the-asynchronous-client) + ### Generate a client access token ```java readme-sample-getChatClientAccessToken @@ -212,6 +230,9 @@ ChatTopic topic = client.createOrReplaceTopic("general", "announcements", String conversationId = topic.getConversationId(); ``` +When creating a topic, leave `state` unset (as above) or set it to +`ChatTopicState.NORMAL`. Other states are only valid when updating an existing topic. + Use the returned conversation ID when a Chat WebSocket client sends messages to the topic. This server-side library manages resources and persisted messages; it is not a WebSocket chat client. diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/assets.json b/sdk/webpubsub/azure-messaging-webpubsub-chat/assets.json index 6927e8604a559..694f2beae03b2 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/assets.json +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/assets.json @@ -1 +1 @@ -{"AssetsRepo":"Azure/azure-sdk-assets","AssetsRepoPrefixPath":"java","TagPrefix":"java/webpubsub/azure-messaging-webpubsub-chat","Tag": "java/webpubsub/azure-messaging-webpubsub-chat_a649b09111"} \ No newline at end of file +{"AssetsRepo":"Azure/azure-sdk-assets","AssetsRepoPrefixPath":"java","TagPrefix":"java/webpubsub/azure-messaging-webpubsub-chat","Tag": "java/webpubsub/azure-messaging-webpubsub-chat_ab082b0a0c"} \ No newline at end of file diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/src/main/java/WebPubSubChatCustomization.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/src/main/java/WebPubSubChatCustomization.java index dc1753044eb98..ac6f6f50a791e 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/src/main/java/WebPubSubChatCustomization.java +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/src/main/java/WebPubSubChatCustomization.java @@ -100,9 +100,21 @@ static String correctLifecycleDocumentation(String source) { } corrected = corrected.substring(0, requestStart) + request + corrected.substring(responseStart); } + if (method.getNameAsString().startsWith("createOrReplaceTopic") + && !corrected.contains("When creating a topic, omit state")) { + corrected = corrected.replace("Create or replace a topic.", + "Create or replace a topic.\n *\n" + + " *

When creating a topic, omit state or set it to Normal. " + + "Other states are only valid when updating an existing topic.

"); + } if (method.getNameAsString().equals("setState")) { corrected = corrected.replace("Required when create the resource.", - "Optional when creating a topic. Set this property to change the topic state when updating it."); + "When creating a topic, omit this property or set it to {@link ChatTopicState#NORMAL}. " + + "Other states are only valid when updating an existing topic."); + corrected = corrected.replace( + "Optional when creating a topic. Set this property to change the topic state when updating it.", + "When creating a topic, omit this property or set it to {@link ChatTopicState#NORMAL}. " + + "Other states are only valid when updating an existing topic."); } if (!original.equals(corrected)) { source = source.replace(original, corrected); diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/src/test/java/WebPubSubChatDocumentationTests.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/src/test/java/WebPubSubChatDocumentationTests.java index afca5599c7574..c4fd49f4a1a49 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/src/test/java/WebPubSubChatDocumentationTests.java +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/src/test/java/WebPubSubChatDocumentationTests.java @@ -201,13 +201,31 @@ public void stateSetterDoesNotRequireStateOnCreate() throws IOException { .filter(method -> method.getNameAsString().equals("setState")) .findFirst() .get(); - String doc = setter.getJavadocComment().get().getContent(); - assertTrue(doc.contains("Optional when creating a topic.")); + String doc = setter.getJavadocComment().get().getContent().replaceAll("\\s*\\R\\s*\\*\\s*", " "); + assertTrue(doc.contains("When creating a topic, omit this property")); + assertTrue(doc.contains("{@link ChatTopicState#NORMAL}")); + assertTrue(doc.contains("Other states are only valid when updating an existing topic.")); assertFalse(doc.contains("Required when create")); String original = "/**\n *

Required when create the resource.

\n */\n" + "class Example { /**

Required when create the resource.

*/ void setState() {} }"; assertTrue(WebPubSubChatCustomization.correctLifecycleDocumentation(original) - .contains("Optional when creating a topic.")); + .contains("When creating a topic, omit this property")); + } + + @Test + public void topicCreationDocumentsAllowedInitialState() throws IOException { + for (String file : Arrays.asList("WebPubSubChatServiceClient.java", "WebPubSubChatServiceAsyncClient.java", + "implementation/WebPubSubChatServiceClientImpl.java")) { + for (MethodDeclaration method : StaticJavaParser.parse(SOURCE.resolve(file)) + .findAll(MethodDeclaration.class)) { + if (method.getNameAsString().startsWith("createOrReplaceTopic") + && method.getJavadocComment().isPresent()) { + String doc = method.getJavadocComment().get().getContent().replaceAll("\\s*\\R\\s*\\*\\s*", " "); + assertTrue(doc.contains("When creating a topic, omit state or set it to Normal."), file); + assertTrue(doc.contains("Other states are only valid when updating an existing topic."), file); + } + } + } } private static String withoutComments(String source) { diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceAsyncClient.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceAsyncClient.java index b058960fea117..25b2096b1057e 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceAsyncClient.java +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceAsyncClient.java @@ -1730,6 +1730,9 @@ public PagedFlux listTopics(String roomId, RequestOptions requestOpt /** * Create or replace a topic. * + *

When creating a topic, omit state or set it to Normal. Other states are only valid when updating an existing + * topic.

+ * * Create or replace a topic with a client-specified ID. *

Header Parameters

* @@ -2154,6 +2157,9 @@ public PagedFlux listTopics(String roomId) { /** * Create or replace a topic. * + *

When creating a topic, omit state or set it to Normal. Other states are only valid when updating an existing + * topic.

+ * * Create or replace a topic with a client-specified ID. * * @param roomId Room identifier. @@ -2190,6 +2196,9 @@ public Mono createOrReplaceTopic(String roomId, String topicId, ChatT /** * Create or replace a topic. * + *

When creating a topic, omit state or set it to Normal. Other states are only valid when updating an existing + * topic.

+ * * Create or replace a topic with a client-specified ID. * * @param roomId Room identifier. diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceClient.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceClient.java index 4edc65013d833..d3ed05f41b000 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceClient.java +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceClient.java @@ -1586,6 +1586,9 @@ public PagedIterable listTopics(String roomId, RequestOptions reques /** * Create or replace a topic. * + *

When creating a topic, omit state or set it to Normal. Other states are only valid when updating an existing + * topic.

+ * * Create or replace a topic with a client-specified ID. *

Header Parameters

*
@@ -1935,6 +1938,9 @@ public PagedIterable listTopics(String roomId) { /** * Create or replace a topic. * + *

When creating a topic, omit state or set it to Normal. Other states are only valid when updating an existing + * topic.

+ * * Create or replace a topic with a client-specified ID. * * @param roomId Room identifier. @@ -1971,6 +1977,9 @@ public ChatTopic createOrReplaceTopic(String roomId, String topicId, ChatTopic r /** * Create or replace a topic. * + *

When creating a topic, omit state or set it to Normal. Other states are only valid when updating an existing + * topic.

+ * * Create or replace a topic with a client-specified ID. * * @param roomId Room identifier. diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/implementation/WebPubSubChatServiceClientImpl.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/implementation/WebPubSubChatServiceClientImpl.java index 36f0d96e366ce..efdd09cdcf295 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/implementation/WebPubSubChatServiceClientImpl.java +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/implementation/WebPubSubChatServiceClientImpl.java @@ -2487,6 +2487,9 @@ public PagedIterable listTopics(String roomId, RequestOptions reques /** * Create or replace a topic. * + *

When creating a topic, omit state or set it to Normal. Other states are only valid when updating an existing + * topic.

+ * * Create or replace a topic with a client-specified ID. *

Header Parameters

*
@@ -2555,6 +2558,9 @@ public Mono> createOrReplaceTopicWithResponseAsync(String r /** * Create or replace a topic. * + *

When creating a topic, omit state or set it to Normal. Other states are only valid when updating an existing + * topic.

+ * * Create or replace a topic with a client-specified ID. *

Header Parameters

*
diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/ChatTopic.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/ChatTopic.java index bc88940454b2c..44ae5c266f95a 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/ChatTopic.java +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/ChatTopic.java @@ -167,7 +167,8 @@ public ChatTopicState getState() { /** * Set the state property: Current lifecycle state of the topic. - *

Optional when creating a topic. Set this property to change the topic state when updating it.

+ *

When creating a topic, omit this property or set it to {@link ChatTopicState#NORMAL}. Other states are only + * valid when updating an existing topic.

* * @param state the state value to set. * @return the ChatTopic object itself. diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/ChatServiceAugustAsyncClientLiveTests.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/ChatServiceAugustAsyncClientLiveTests.java deleted file mode 100644 index 037840fa32f8f..0000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/ChatServiceAugustAsyncClientLiveTests.java +++ /dev/null @@ -1,172 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.messaging.webpubsub.chat; - -import com.azure.core.exception.HttpResponseException; -import com.azure.core.http.MatchConditions; -import com.azure.core.http.rest.PagedResponse; -import com.azure.messaging.webpubsub.chat.models.BuiltInChatRoles; -import com.azure.messaging.webpubsub.chat.models.ChatRoom; -import com.azure.messaging.webpubsub.chat.models.ChatRoomMember; -import com.azure.messaging.webpubsub.chat.models.ChatTopic; -import com.azure.messaging.webpubsub.chat.models.ChatTopicState; -import com.azure.messaging.webpubsub.chat.models.ChatUser; -import com.azure.messaging.webpubsub.chat.models.ChatUserRoom; -import com.azure.messaging.webpubsub.chat.models.HumanChatUser; -import org.junit.jupiter.api.Test; - -import java.util.List; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class ChatServiceAugustAsyncClientLiveTests extends ChatServiceClientTestBase { - @Test - public void canManageTopicsWithConditionsAndPagination() { - String roomId = testResourceNamer.randomName("java-async-topic-room-", 55); - String firstTopicId = "first"; - String secondTopicId = "second"; - - try { - asyncClient.createOrReplaceRoom(roomId, new ChatRoom("Java async topic test room")).block(); - ChatTopic created - = asyncClient - .createOrReplaceTopic(roomId, firstTopicId, new ChatTopic().setTitle("First topic"), - new MatchConditions().setIfNoneMatch("*")) - .block(); - assertEquals(firstTopicId, created.getId()); - assertEquals(ChatTopicState.NORMAL, created.getState()); - assertNotNull(created.getCreatedAt()); - assertNotNull(created.getCreatedBy()); - assertNotNull(created.getConversationId()); - assertNotNull(created.getEtag()); - assertEquals("First topic", entraAsyncClient.getTopic(roomId, firstTopicId).block().getTitle()); - - HttpResponseException duplicate = assertThrows(HttpResponseException.class, - () -> asyncClient - .createOrReplaceTopic(roomId, firstTopicId, new ChatTopic().setTitle("Duplicate"), - new MatchConditions().setIfNoneMatch("*")) - .block()); - assertEquals(412, duplicate.getResponse().getStatusCode()); - ChatTopic replaced - = asyncClient - .createOrReplaceTopic(roomId, firstTopicId, new ChatTopic().setTitle("Replaced topic"), - new MatchConditions().setIfMatch(created.getEtag())) - .block(); - ChatTopic updated - = asyncClient - .updateTopic(roomId, firstTopicId, - new ChatTopic().setTitle("Updated topic").setState(ChatTopicState.ARCHIVED), - new MatchConditions().setIfMatch(replaced.getEtag())) - .block(); - assertEquals("Updated topic", updated.getTitle()); - assertEquals(ChatTopicState.ARCHIVED, updated.getState()); - assertEquals(created.getConversationId(), updated.getConversationId()); - HttpResponseException stale = assertThrows(HttpResponseException.class, - () -> asyncClient - .updateTopic(roomId, firstTopicId, new ChatTopic().setTitle("Stale update"), - new MatchConditions().setIfMatch(replaced.getEtag())) - .block()); - assertEquals(412, stale.getResponse().getStatusCode()); - - asyncClient.createOrReplaceTopic(roomId, secondTopicId, new ChatTopic().setTitle("Second topic")).block(); - List> pages - = asyncClient.listTopics(roomId).byPage(1).take(2).collectList().block(); - assertEquals(2, pages.size()); - assertEquals(1, pages.get(0).getValue().size()); - assertNotNull(pages.get(0).getContinuationToken()); - assertEquals(1, pages.get(1).getValue().size()); - assertNotEquals(pages.get(0).getValue().get(0).getId(), pages.get(1).getValue().get(0).getId()); - List topicIds = asyncClient.listTopics(roomId).map(ChatTopic::getId).collectList().block(); - assertTrue(topicIds.contains(firstTopicId)); - assertTrue(topicIds.contains(secondTopicId)); - - asyncClient.deleteTopic(roomId, firstTopicId, new MatchConditions().setIfMatch(updated.getEtag())).block(); - asyncClient.deleteTopic(roomId, secondTopicId).block(); - } finally { - cleanup(() -> asyncClient.deleteRoom(roomId).block()); - } - } - - @Test - public void canListRoomsAndUsersWithPagination() { - String suffix = testResourceNamer.randomName("java", 20); - String firstRoomId = "java-async-list-room-a-" + suffix; - String secondRoomId = "java-async-list-room-b-" + suffix; - String firstUserId = "java-async-list-user-a-" + suffix; - String secondUserId = "java-async-list-user-b-" + suffix; - - try { - asyncClient.createOrReplaceRoom(firstRoomId, new ChatRoom("First room")).block(); - asyncClient.createOrReplaceRoom(secondRoomId, new ChatRoom("Second room")).block(); - asyncClient.createOrReplaceUser(firstUserId, new HumanChatUser("First user", BuiltInChatRoles.USER_NORMAL)) - .block(); - asyncClient - .createOrReplaceUser(secondUserId, new HumanChatUser("Second user", BuiltInChatRoles.USER_NORMAL)) - .block(); - - List roomIds = asyncClient.listRooms() - .byPage(1) - .flatMapIterable(PagedResponse::getValue) - .map(ChatRoom::getId) - .collectList() - .block(); - assertTrue(roomIds.contains(firstRoomId)); - assertTrue(roomIds.contains(secondRoomId)); - List users - = entraAsyncClient.listUsers().byPage(1).flatMapIterable(PagedResponse::getValue).collectList().block(); - assertTrue( - users.stream().anyMatch(user -> firstUserId.equals(user.getId()) && user instanceof HumanChatUser)); - assertTrue(users.stream().anyMatch(user -> secondUserId.equals(user.getId()))); - } finally { - cleanup(() -> asyncClient.deleteRoom(firstRoomId).block()); - cleanup(() -> asyncClient.deleteRoom(secondRoomId).block()); - cleanup(() -> asyncClient.deleteUser(firstUserId).block()); - cleanup(() -> asyncClient.deleteUser(secondUserId).block()); - } - } - - @Test - public void canListRoomsForUserWithPagination() { - String suffix = testResourceNamer.randomName("java", 20); - String userId = "java-async-user-rooms-" + suffix; - String firstRoomId = "java-async-user-room-a-" + suffix; - String secondRoomId = "java-async-user-room-b-" + suffix; - - try { - asyncClient.createOrReplaceUser(userId, new HumanChatUser("Room list user", BuiltInChatRoles.USER_NORMAL)) - .block(); - asyncClient.createOrReplaceRoom(firstRoomId, new ChatRoom("First user room")).block(); - asyncClient.createOrReplaceRoom(secondRoomId, new ChatRoom("Second user room")).block(); - assertEquals(0, asyncClient.listRoomsForUser(userId).count().block()); - asyncClient.createOrReplaceRoomMember(firstRoomId, userId, new ChatRoomMember(BuiltInChatRoles.ROOM_MEMBER)) - .block(); - asyncClient - .createOrReplaceRoomMember(secondRoomId, userId, new ChatRoomMember(BuiltInChatRoles.ROOM_MEMBER)) - .block(); - - List> pages - = asyncClient.listRoomsForUser(userId).byPage(1).collectList().block(); - assertEquals(2, pages.size()); - assertEquals(1, pages.get(0).getValue().size()); - assertNotNull(pages.get(0).getContinuationToken()); - assertEquals(1, pages.get(1).getValue().size()); - assertNotEquals(pages.get(0).getValue().get(0).getId(), pages.get(1).getValue().get(0).getId()); - List rooms = asyncClient.listRoomsForUser(userId).collectList().block(); - assertEquals(2, rooms.size()); - assertTrue(rooms.stream() - .anyMatch(room -> firstRoomId.equals(room.getId()) - && "First user room".equals(room.getTitle()) - && room.getDefaultConversation() != null)); - assertTrue(rooms.stream().anyMatch(room -> secondRoomId.equals(room.getId()))); - } finally { - cleanup(() -> asyncClient.deleteRoom(firstRoomId).block()); - cleanup(() -> asyncClient.deleteRoom(secondRoomId).block()); - cleanup(() -> asyncClient.deleteUser(userId).block()); - } - } -} diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/ChatServiceAugustClientLiveTests.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/ChatServiceAugustClientLiveTests.java deleted file mode 100644 index 2a6d91ca3b5a8..0000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/ChatServiceAugustClientLiveTests.java +++ /dev/null @@ -1,156 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.messaging.webpubsub.chat; - -import com.azure.core.exception.HttpResponseException; -import com.azure.core.http.MatchConditions; -import com.azure.core.http.rest.PagedResponse; -import com.azure.messaging.webpubsub.chat.models.BuiltInChatRoles; -import com.azure.messaging.webpubsub.chat.models.ChatRoom; -import com.azure.messaging.webpubsub.chat.models.ChatRoomMember; -import com.azure.messaging.webpubsub.chat.models.ChatTopic; -import com.azure.messaging.webpubsub.chat.models.ChatTopicState; -import com.azure.messaging.webpubsub.chat.models.ChatUser; -import com.azure.messaging.webpubsub.chat.models.ChatUserRoom; -import com.azure.messaging.webpubsub.chat.models.HumanChatUser; -import org.junit.jupiter.api.Test; - -import java.util.Iterator; -import java.util.List; -import java.util.stream.Collectors; -import java.util.stream.StreamSupport; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class ChatServiceAugustClientLiveTests extends ChatServiceClientTestBase { - @Test - public void canManageTopicsWithConditionsAndPagination() { - String roomId = testResourceNamer.randomName("java-topic-room-", 50); - String firstTopicId = "first"; - String secondTopicId = "second"; - - try { - client.createOrReplaceRoom(roomId, new ChatRoom("Java topic test room")); - ChatTopic created = client.createOrReplaceTopic(roomId, firstTopicId, - new ChatTopic().setTitle("First topic"), new MatchConditions().setIfNoneMatch("*")); - assertEquals(firstTopicId, created.getId()); - assertEquals(ChatTopicState.NORMAL, created.getState()); - assertNotNull(created.getCreatedAt()); - assertNotNull(created.getCreatedBy()); - assertNotNull(created.getConversationId()); - assertNotNull(created.getEtag()); - assertEquals("First topic", entraClient.getTopic(roomId, firstTopicId).getTitle()); - - HttpResponseException duplicate - = assertThrows(HttpResponseException.class, () -> client.createOrReplaceTopic(roomId, firstTopicId, - new ChatTopic().setTitle("Duplicate"), new MatchConditions().setIfNoneMatch("*"))); - assertEquals(412, duplicate.getResponse().getStatusCode()); - - ChatTopic replaced = client.createOrReplaceTopic(roomId, firstTopicId, - new ChatTopic().setTitle("Replaced topic"), new MatchConditions().setIfMatch(created.getEtag())); - ChatTopic updated = client.updateTopic(roomId, firstTopicId, - new ChatTopic().setTitle("Updated topic").setState(ChatTopicState.ARCHIVED), - new MatchConditions().setIfMatch(replaced.getEtag())); - assertEquals("Updated topic", updated.getTitle()); - assertEquals(ChatTopicState.ARCHIVED, updated.getState()); - assertEquals(created.getConversationId(), updated.getConversationId()); - HttpResponseException stale - = assertThrows(HttpResponseException.class, () -> client.updateTopic(roomId, firstTopicId, - new ChatTopic().setTitle("Stale update"), new MatchConditions().setIfMatch(replaced.getEtag()))); - assertEquals(412, stale.getResponse().getStatusCode()); - - client.createOrReplaceTopic(roomId, secondTopicId, new ChatTopic().setTitle("Second topic")); - Iterator> pages = client.listTopics(roomId).iterableByPage(1).iterator(); - PagedResponse firstPage = pages.next(); - assertEquals(1, firstPage.getValue().size()); - assertNotNull(firstPage.getContinuationToken()); - PagedResponse secondPage = pages.next(); - assertEquals(1, secondPage.getValue().size()); - assertNotEquals(firstPage.getValue().get(0).getId(), secondPage.getValue().get(0).getId()); - List topicIds - = client.listTopics(roomId).stream().map(ChatTopic::getId).collect(Collectors.toList()); - assertTrue(topicIds.contains(firstTopicId)); - assertTrue(topicIds.contains(secondTopicId)); - - client.deleteTopic(roomId, firstTopicId, new MatchConditions().setIfMatch(updated.getEtag())); - client.deleteTopic(roomId, secondTopicId); - } finally { - cleanup(() -> client.deleteRoom(roomId)); - } - } - - @Test - public void canListRoomsAndUsersWithPagination() { - String suffix = testResourceNamer.randomName("java", 20); - String firstRoomId = "java-list-room-a-" + suffix; - String secondRoomId = "java-list-room-b-" + suffix; - String firstUserId = "java-list-user-a-" + suffix; - String secondUserId = "java-list-user-b-" + suffix; - - try { - client.createOrReplaceRoom(firstRoomId, new ChatRoom("First room")); - client.createOrReplaceRoom(secondRoomId, new ChatRoom("Second room")); - client.createOrReplaceUser(firstUserId, new HumanChatUser("First user", BuiltInChatRoles.USER_NORMAL)); - client.createOrReplaceUser(secondUserId, new HumanChatUser("Second user", BuiltInChatRoles.USER_NORMAL)); - - List roomIds = StreamSupport.stream(client.listRooms().iterableByPage(1).spliterator(), false) - .flatMap(page -> page.getValue().stream()) - .map(ChatRoom::getId) - .collect(Collectors.toList()); - assertTrue(roomIds.contains(firstRoomId)); - assertTrue(roomIds.contains(secondRoomId)); - List users = StreamSupport.stream(entraClient.listUsers().iterableByPage(1).spliterator(), false) - .flatMap(page -> page.getValue().stream()) - .collect(Collectors.toList()); - assertTrue( - users.stream().anyMatch(user -> firstUserId.equals(user.getId()) && user instanceof HumanChatUser)); - assertTrue(users.stream().anyMatch(user -> secondUserId.equals(user.getId()))); - } finally { - cleanup(() -> client.deleteRoom(firstRoomId)); - cleanup(() -> client.deleteRoom(secondRoomId)); - cleanup(() -> client.deleteUser(firstUserId)); - cleanup(() -> client.deleteUser(secondUserId)); - } - } - - @Test - public void canListRoomsForUserWithPagination() { - String suffix = testResourceNamer.randomName("java", 20); - String userId = "java-user-rooms-" + suffix; - String firstRoomId = "java-user-room-a-" + suffix; - String secondRoomId = "java-user-room-b-" + suffix; - - try { - client.createOrReplaceUser(userId, new HumanChatUser("Room list user", BuiltInChatRoles.USER_NORMAL)); - client.createOrReplaceRoom(firstRoomId, new ChatRoom("First user room")); - client.createOrReplaceRoom(secondRoomId, new ChatRoom("Second user room")); - assertEquals(0, client.listRoomsForUser(userId).stream().count()); - client.createOrReplaceRoomMember(firstRoomId, userId, new ChatRoomMember(BuiltInChatRoles.ROOM_MEMBER)); - client.createOrReplaceRoomMember(secondRoomId, userId, new ChatRoomMember(BuiltInChatRoles.ROOM_MEMBER)); - - Iterator> pages = client.listRoomsForUser(userId).iterableByPage(1).iterator(); - PagedResponse firstPage = pages.next(); - assertEquals(1, firstPage.getValue().size()); - assertNotNull(firstPage.getContinuationToken()); - PagedResponse secondPage = pages.next(); - assertEquals(1, secondPage.getValue().size()); - assertNotEquals(firstPage.getValue().get(0).getId(), secondPage.getValue().get(0).getId()); - List rooms = client.listRoomsForUser(userId).stream().collect(Collectors.toList()); - assertEquals(2, rooms.size()); - assertTrue(rooms.stream() - .anyMatch(room -> firstRoomId.equals(room.getId()) - && "First user room".equals(room.getTitle()) - && room.getDefaultConversation() != null)); - assertTrue(rooms.stream().anyMatch(room -> secondRoomId.equals(room.getId()))); - } finally { - cleanup(() -> client.deleteRoom(firstRoomId)); - cleanup(() -> client.deleteRoom(secondRoomId)); - cleanup(() -> client.deleteUser(userId)); - } - } -} diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/ChatServiceClientLiveTests.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/ChatServiceClientLiveTests.java index eb034175b7713..a0e4ba2691446 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/ChatServiceClientLiveTests.java +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/ChatServiceClientLiveTests.java @@ -7,6 +7,7 @@ import com.azure.core.http.MatchConditions; import com.azure.core.http.rest.PagedResponse; import com.azure.core.test.TestMode; +import com.azure.core.test.annotation.SyncAsyncTest; import com.azure.messaging.webpubsub.chat.models.BuiltInChatRoles; import com.azure.messaging.webpubsub.chat.models.ChatConversation; import com.azure.messaging.webpubsub.chat.models.ChatMessage; @@ -14,25 +15,229 @@ import com.azure.messaging.webpubsub.chat.models.ChatRole; import com.azure.messaging.webpubsub.chat.models.ChatRoom; import com.azure.messaging.webpubsub.chat.models.ChatRoomMember; +import com.azure.messaging.webpubsub.chat.models.ChatTopic; +import com.azure.messaging.webpubsub.chat.models.ChatTopicState; import com.azure.messaging.webpubsub.chat.models.ChatUser; +import com.azure.messaging.webpubsub.chat.models.ChatUserRoom; import com.azure.messaging.webpubsub.chat.models.GetClientAccessTokenOptions; import com.azure.messaging.webpubsub.chat.models.HumanChatUser; import com.azure.messaging.webpubsub.chat.models.MessageContent; import com.azure.messaging.webpubsub.chat.models.WebPubSubClientAccessToken; import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; import java.util.Arrays; import java.util.Collections; import java.util.Iterator; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.StreamSupport; +import static com.azure.core.test.SyncAsyncExtension.execute; import static org.junit.jupiter.api.Assertions.assertArrayEquals; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; public class ChatServiceClientLiveTests extends ChatServiceClientTestBase { + @SyncAsyncTest + public void canManageTopicsWithConditionsAndPagination() { + String roomId = execute(() -> testResourceNamer.randomName("java-topic-room-", 50), + () -> Mono.just(testResourceNamer.randomName("java-async-topic-room-", 55))); + String title = execute(() -> "Java topic test room", () -> Mono.just("Java async topic test room")); + String firstTopicId = "first"; + String secondTopicId = "second"; + + try { + execute(() -> client.createOrReplaceRoom(roomId, new ChatRoom(title)), + () -> asyncClient.createOrReplaceRoom(roomId, new ChatRoom(title))); + ChatTopic created = execute( + () -> client.createOrReplaceTopic(roomId, firstTopicId, new ChatTopic().setTitle("First topic"), + new MatchConditions().setIfNoneMatch("*")), + () -> asyncClient.createOrReplaceTopic(roomId, firstTopicId, new ChatTopic().setTitle("First topic"), + new MatchConditions().setIfNoneMatch("*"))); + assertEquals(firstTopicId, created.getId()); + assertEquals(ChatTopicState.NORMAL, created.getState()); + assertNotNull(created.getCreatedAt()); + assertNotNull(created.getCreatedBy()); + assertNotNull(created.getConversationId()); + assertNotNull(created.getEtag()); + assertEquals("First topic", execute(() -> entraClient.getTopic(roomId, firstTopicId), + () -> entraAsyncClient.getTopic(roomId, firstTopicId)).getTitle()); + + HttpResponseException duplicate = assertThrows(HttpResponseException.class, + () -> execute( + () -> client.createOrReplaceTopic(roomId, firstTopicId, new ChatTopic().setTitle("Duplicate"), + new MatchConditions().setIfNoneMatch("*")), + () -> asyncClient.createOrReplaceTopic(roomId, firstTopicId, new ChatTopic().setTitle("Duplicate"), + new MatchConditions().setIfNoneMatch("*")))); + assertEquals(412, duplicate.getResponse().getStatusCode()); + + ChatTopic replaced = execute( + () -> client.createOrReplaceTopic(roomId, firstTopicId, new ChatTopic().setTitle("Replaced topic"), + new MatchConditions().setIfMatch(created.getEtag())), + () -> asyncClient.createOrReplaceTopic(roomId, firstTopicId, new ChatTopic().setTitle("Replaced topic"), + new MatchConditions().setIfMatch(created.getEtag()))); + ChatTopic updated = execute( + () -> client.updateTopic(roomId, firstTopicId, + new ChatTopic().setTitle("Updated topic").setState(ChatTopicState.ARCHIVED), + new MatchConditions().setIfMatch(replaced.getEtag())), + () -> asyncClient.updateTopic(roomId, firstTopicId, + new ChatTopic().setTitle("Updated topic").setState(ChatTopicState.ARCHIVED), + new MatchConditions().setIfMatch(replaced.getEtag()))); + assertEquals("Updated topic", updated.getTitle()); + assertEquals(ChatTopicState.ARCHIVED, updated.getState()); + assertEquals(created.getConversationId(), updated.getConversationId()); + HttpResponseException stale = assertThrows(HttpResponseException.class, + () -> execute( + () -> client.updateTopic(roomId, firstTopicId, new ChatTopic().setTitle("Stale update"), + new MatchConditions().setIfMatch(replaced.getEtag())), + () -> asyncClient.updateTopic(roomId, firstTopicId, new ChatTopic().setTitle("Stale update"), + new MatchConditions().setIfMatch(replaced.getEtag())))); + assertEquals(412, stale.getResponse().getStatusCode()); + + execute(() -> client.createOrReplaceTopic(roomId, secondTopicId, new ChatTopic().setTitle("Second topic")), + () -> asyncClient.createOrReplaceTopic(roomId, secondTopicId, + new ChatTopic().setTitle("Second topic"))); + List> pages = execute( + () -> StreamSupport.stream(client.listTopics(roomId).iterableByPage(1).spliterator(), false) + .limit(2) + .collect(Collectors.toList()), + () -> asyncClient.listTopics(roomId).byPage(1).take(2).collectList()); + assertEquals(2, pages.size()); + assertEquals(1, pages.get(0).getValue().size()); + assertNotNull(pages.get(0).getContinuationToken()); + assertEquals(1, pages.get(1).getValue().size()); + assertNotEquals(pages.get(0).getValue().get(0).getId(), pages.get(1).getValue().get(0).getId()); + List topicIds + = execute(() -> client.listTopics(roomId).stream().map(ChatTopic::getId).collect(Collectors.toList()), + () -> asyncClient.listTopics(roomId).map(ChatTopic::getId).collectList()); + assertTrue(topicIds.contains(firstTopicId)); + assertTrue(topicIds.contains(secondTopicId)); + + execute(() -> client.deleteTopic(roomId, firstTopicId, new MatchConditions().setIfMatch(updated.getEtag())), + () -> asyncClient.deleteTopic(roomId, firstTopicId, + new MatchConditions().setIfMatch(updated.getEtag()))); + execute(() -> client.deleteTopic(roomId, secondTopicId), + () -> asyncClient.deleteTopic(roomId, secondTopicId)); + } finally { + cleanup(() -> execute(() -> client.deleteRoom(roomId), () -> asyncClient.deleteRoom(roomId))); + } + } + + @SyncAsyncTest + public void canListRoomsAndUsersWithPagination() { + String suffix = testResourceNamer.randomName("java", 20); + String prefix = execute(() -> "java", () -> Mono.just("java-async")); + String firstRoomId = prefix + "-list-room-a-" + suffix; + String secondRoomId = prefix + "-list-room-b-" + suffix; + String firstUserId = prefix + "-list-user-a-" + suffix; + String secondUserId = prefix + "-list-user-b-" + suffix; + + try { + execute(() -> client.createOrReplaceRoom(firstRoomId, new ChatRoom("First room")), + () -> asyncClient.createOrReplaceRoom(firstRoomId, new ChatRoom("First room"))); + execute(() -> client.createOrReplaceRoom(secondRoomId, new ChatRoom("Second room")), + () -> asyncClient.createOrReplaceRoom(secondRoomId, new ChatRoom("Second room"))); + execute( + () -> client.createOrReplaceUser(firstUserId, + new HumanChatUser("First user", BuiltInChatRoles.USER_NORMAL)), + () -> asyncClient.createOrReplaceUser(firstUserId, + new HumanChatUser("First user", BuiltInChatRoles.USER_NORMAL))); + execute( + () -> client.createOrReplaceUser(secondUserId, + new HumanChatUser("Second user", BuiltInChatRoles.USER_NORMAL)), + () -> asyncClient.createOrReplaceUser(secondUserId, + new HumanChatUser("Second user", BuiltInChatRoles.USER_NORMAL))); + + List roomIds = execute( + () -> StreamSupport.stream(client.listRooms().iterableByPage(1).spliterator(), false) + .flatMap(page -> page.getValue().stream()) + .map(ChatRoom::getId) + .collect(Collectors.toList()), + () -> asyncClient.listRooms() + .byPage(1) + .flatMapIterable(PagedResponse::getValue) + .map(ChatRoom::getId) + .collectList()); + assertTrue(roomIds.contains(firstRoomId)); + assertTrue(roomIds.contains(secondRoomId)); + List users = execute( + () -> StreamSupport.stream(entraClient.listUsers().iterableByPage(1).spliterator(), false) + .flatMap(page -> page.getValue().stream()) + .collect(Collectors.toList()), + () -> entraAsyncClient.listUsers().byPage(1).flatMapIterable(PagedResponse::getValue).collectList()); + assertTrue( + users.stream().anyMatch(user -> firstUserId.equals(user.getId()) && user instanceof HumanChatUser)); + assertTrue(users.stream().anyMatch(user -> secondUserId.equals(user.getId()))); + } finally { + cleanup(() -> execute(() -> client.deleteRoom(firstRoomId), () -> asyncClient.deleteRoom(firstRoomId))); + cleanup(() -> execute(() -> client.deleteRoom(secondRoomId), () -> asyncClient.deleteRoom(secondRoomId))); + cleanup(() -> execute(() -> client.deleteUser(firstUserId), () -> asyncClient.deleteUser(firstUserId))); + cleanup(() -> execute(() -> client.deleteUser(secondUserId), () -> asyncClient.deleteUser(secondUserId))); + } + } + + @SyncAsyncTest + public void canListRoomsForUserWithPagination() { + String suffix = testResourceNamer.randomName("java", 20); + String prefix = execute(() -> "java", () -> Mono.just("java-async")); + String userId = prefix + "-user-rooms-" + suffix; + String firstRoomId = prefix + "-user-room-a-" + suffix; + String secondRoomId = prefix + "-user-room-b-" + suffix; + + try { + execute( + () -> client.createOrReplaceUser(userId, + new HumanChatUser("Room list user", BuiltInChatRoles.USER_NORMAL)), + () -> asyncClient.createOrReplaceUser(userId, + new HumanChatUser("Room list user", BuiltInChatRoles.USER_NORMAL))); + execute(() -> client.createOrReplaceRoom(firstRoomId, new ChatRoom("First user room")), + () -> asyncClient.createOrReplaceRoom(firstRoomId, new ChatRoom("First user room"))); + execute(() -> client.createOrReplaceRoom(secondRoomId, new ChatRoom("Second user room")), + () -> asyncClient.createOrReplaceRoom(secondRoomId, new ChatRoom("Second user room"))); + assertEquals(0L, execute(() -> client.listRoomsForUser(userId).stream().count(), + () -> asyncClient.listRoomsForUser(userId).count())); + execute( + () -> client.createOrReplaceRoomMember(firstRoomId, userId, + new ChatRoomMember(BuiltInChatRoles.ROOM_MEMBER)), + () -> asyncClient.createOrReplaceRoomMember(firstRoomId, userId, + new ChatRoomMember(BuiltInChatRoles.ROOM_MEMBER))); + execute( + () -> client.createOrReplaceRoomMember(secondRoomId, userId, + new ChatRoomMember(BuiltInChatRoles.ROOM_MEMBER)), + () -> asyncClient.createOrReplaceRoomMember(secondRoomId, userId, + new ChatRoomMember(BuiltInChatRoles.ROOM_MEMBER))); + + List> pages + = execute( + () -> StreamSupport.stream(client.listRoomsForUser(userId).iterableByPage(1).spliterator(), false) + .collect(Collectors.toList()), + () -> asyncClient.listRoomsForUser(userId).byPage(1).collectList()); + assertEquals(2, pages.size()); + assertEquals(1, pages.get(0).getValue().size()); + assertNotNull(pages.get(0).getContinuationToken()); + assertEquals(1, pages.get(1).getValue().size()); + assertNotEquals(pages.get(0).getValue().get(0).getId(), pages.get(1).getValue().get(0).getId()); + List rooms + = execute(() -> client.listRoomsForUser(userId).stream().collect(Collectors.toList()), + () -> asyncClient.listRoomsForUser(userId).collectList()); + assertEquals(2, rooms.size()); + assertTrue(rooms.stream() + .anyMatch(room -> firstRoomId.equals(room.getId()) + && "First user room".equals(room.getTitle()) + && room.getDefaultConversation() != null)); + assertTrue(rooms.stream().anyMatch(room -> secondRoomId.equals(room.getId()))); + } finally { + cleanup(() -> execute(() -> client.deleteRoom(firstRoomId), () -> asyncClient.deleteRoom(firstRoomId))); + cleanup(() -> execute(() -> client.deleteRoom(secondRoomId), () -> asyncClient.deleteRoom(secondRoomId))); + cleanup(() -> execute(() -> client.deleteUser(userId), () -> asyncClient.deleteUser(userId))); + } + } + @Test public void canManageRolesWithConditionsAndPagination() { String firstRoleName = testResourceNamer.randomName("user.java-test-", 50); diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceClientBuilderTests.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceClientBuilderTests.java index 5eeadb879500d..8411d365f8b58 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceClientBuilderTests.java +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceClientBuilderTests.java @@ -122,17 +122,6 @@ public void connectionStringRejectsMissingRequiredKeys() { () -> new WebPubSubChatServiceClientBuilder().connectionString("AccessKey=" + FIRST_KEY)); } - @Test - public void defaultServiceVersionIsAugustPreview() { - AtomicReference sentRequest = new AtomicReference<>(); - WebPubSubChatServiceClient client = createClient(new AzureKeyCredential(FIRST_KEY), sentRequest); - - assertThrows(ResourceNotFoundException.class, () -> client.getRole("room.reader")); - - assertEquals("api-version=2026-08-01-preview", sentRequest.get().getUrl().getQuery()); - assertEquals(WebPubSubChatServiceVersion.V2026_08_01_PREVIEW, WebPubSubChatServiceVersion.getLatest()); - } - @ParameterizedTest @EnumSource(WebPubSubChatServiceVersion.class) public void reverseProxyPreservesJavaServiceBehavior(WebPubSubChatServiceVersion serviceVersion) diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/test-resources.bicep b/sdk/webpubsub/azure-messaging-webpubsub-chat/test-resources.bicep index e720664b70705..28932f949d412 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/test-resources.bicep +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/test-resources.bicep @@ -4,10 +4,6 @@ param baseName string = resourceGroup().name @description('This is the object id of the service principal used to run tests.') param testApplicationOid string -@description('Principal type of the identity used to run tests.') -@allowed([ 'ServicePrincipal', 'User' ]) -param testPrincipalType string = 'ServicePrincipal' - @description('Location of the resource.') param location string = resourceGroup().location @@ -127,7 +123,7 @@ resource webPubSubOwnerRoleAssignment 'Microsoft.Authorization/roleAssignments@2 properties: { roleDefinitionId: webPubSubOwnerRoleId principalId: testApplicationOid - principalType: testPrincipalType + principalType: 'ServicePrincipal' } } @@ -137,7 +133,7 @@ resource webPubSubOperatorRoleAssignment 'Microsoft.Authorization/roleAssignment properties: { roleDefinitionId: webPubSubOperatorRoleId principalId: testApplicationOid - principalType: testPrincipalType + principalType: 'ServicePrincipal' } } diff --git a/sdk/webpubsub/tests.yml b/sdk/webpubsub/tests.yml index 3a0bccad48035..75019e939c93e 100644 --- a/sdk/webpubsub/tests.yml +++ b/sdk/webpubsub/tests.yml @@ -4,9 +4,6 @@ extends: template: /eng/pipelines/templates/stages/archetype-sdk-tests.yml parameters: ServiceDirectory: webpubsub - TestResourceDirectories: - - webpubsub - - webpubsub/azure-messaging-webpubsub-chat Artifacts: - name: azure-messaging-webpubsub groupId: com.azure @@ -14,9 +11,6 @@ extends: - name: azure-messaging-webpubsub-client groupId: com.azure safeName: azuremessagingwebpubsubclient - - name: azure-messaging-webpubsub-chat - groupId: com.azure - safeName: azuremessagingwebpubsubchat TimeoutInMinutes: 60 EnvVars: AZURE_LOG_LEVEL: 2 From e26856f9450837e6b35fd2ccb471969f8af19c86 Mon Sep 17 00:00:00 2001 From: Zitong Yang Date: Wed, 28 Oct 2026 16:18:47 +1100 Subject: [PATCH 09/18] Preserve topic state docs and share all live test scenarios Keep setState as an in-place customization and consolidate remaining sync/async tests without re-recording service traffic. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .../assets.json | 2 +- .../main/java/WebPubSubChatCustomization.java | 12 +- .../java/WebPubSubChatDocumentationTests.java | 9 +- .../webpubsub/chat/models/ChatTopic.java | 1 - .../chat/ChatServiceAsyncClientLiveTests.java | 185 ---------------- .../chat/ChatServiceClientLiveTests.java | 204 ++++++++++++------ 6 files changed, 144 insertions(+), 269 deletions(-) delete mode 100644 sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/ChatServiceAsyncClientLiveTests.java diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/assets.json b/sdk/webpubsub/azure-messaging-webpubsub-chat/assets.json index 694f2beae03b2..4e52cc13dbeb5 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/assets.json +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/assets.json @@ -1 +1 @@ -{"AssetsRepo":"Azure/azure-sdk-assets","AssetsRepoPrefixPath":"java","TagPrefix":"java/webpubsub/azure-messaging-webpubsub-chat","Tag": "java/webpubsub/azure-messaging-webpubsub-chat_ab082b0a0c"} \ No newline at end of file +{"AssetsRepo":"Azure/azure-sdk-assets","AssetsRepoPrefixPath":"java","TagPrefix":"java/webpubsub/azure-messaging-webpubsub-chat","Tag": "java/webpubsub/azure-messaging-webpubsub-chat_56e475133e"} \ No newline at end of file diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/src/main/java/WebPubSubChatCustomization.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/src/main/java/WebPubSubChatCustomization.java index ac6f6f50a791e..4dffe6cc8359f 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/src/main/java/WebPubSubChatCustomization.java +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/src/main/java/WebPubSubChatCustomization.java @@ -48,8 +48,7 @@ static void customizeLifecycleDocumentation(LibraryCustomization libraryCustomiz for (String file : new String[] { "WebPubSubChatServiceClient.java", "WebPubSubChatServiceAsyncClient.java", - "implementation/WebPubSubChatServiceClientImpl.java", - "models/ChatTopic.java" }) { + "implementation/WebPubSubChatServiceClientImpl.java" }) { String path = root + file; String source = libraryCustomization.getRawEditor().getFileContent(path); libraryCustomization.getRawEditor().replaceFile(path, correctLifecycleDocumentation(source)); @@ -107,15 +106,6 @@ static String correctLifecycleDocumentation(String source) { + " *

When creating a topic, omit state or set it to Normal. " + "Other states are only valid when updating an existing topic.

"); } - if (method.getNameAsString().equals("setState")) { - corrected = corrected.replace("Required when create the resource.", - "When creating a topic, omit this property or set it to {@link ChatTopicState#NORMAL}. " - + "Other states are only valid when updating an existing topic."); - corrected = corrected.replace( - "Optional when creating a topic. Set this property to change the topic state when updating it.", - "When creating a topic, omit this property or set it to {@link ChatTopicState#NORMAL}. " - + "Other states are only valid when updating an existing topic."); - } if (!original.equals(corrected)) { source = source.replace(original, corrected); } diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/src/test/java/WebPubSubChatDocumentationTests.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/src/test/java/WebPubSubChatDocumentationTests.java index c4fd49f4a1a49..abc66afd11608 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/src/test/java/WebPubSubChatDocumentationTests.java +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/src/test/java/WebPubSubChatDocumentationTests.java @@ -28,7 +28,7 @@ public class WebPubSubChatDocumentationTests { @Test public void generatedDocumentationMatchesCustomization() throws IOException { for (String file : Arrays.asList("WebPubSubChatServiceClient.java", "WebPubSubChatServiceAsyncClient.java", - "implementation/WebPubSubChatServiceClientImpl.java", "models/ChatTopic.java")) { + "implementation/WebPubSubChatServiceClientImpl.java")) { String source = new String(Files.readAllBytes(SOURCE.resolve(file)), StandardCharsets.UTF_8); assertEquals(source, WebPubSubChatCustomization.correctLifecycleDocumentation(source), file); } @@ -194,22 +194,19 @@ public void repairsAllWriteOperations(String operation) { } @Test - public void stateSetterDoesNotRequireStateOnCreate() throws IOException { + public void stateSetterPreservesHandwrittenDocumentation() throws IOException { MethodDeclaration setter = StaticJavaParser.parse(SOURCE.resolve("models/ChatTopic.java")) .findAll(MethodDeclaration.class) .stream() .filter(method -> method.getNameAsString().equals("setState")) .findFirst() .get(); + assertFalse(setter.getAnnotationByName("Generated").isPresent()); String doc = setter.getJavadocComment().get().getContent().replaceAll("\\s*\\R\\s*\\*\\s*", " "); assertTrue(doc.contains("When creating a topic, omit this property")); assertTrue(doc.contains("{@link ChatTopicState#NORMAL}")); assertTrue(doc.contains("Other states are only valid when updating an existing topic.")); assertFalse(doc.contains("Required when create")); - String original = "/**\n *

Required when create the resource.

\n */\n" - + "class Example { /**

Required when create the resource.

*/ void setState() {} }"; - assertTrue(WebPubSubChatCustomization.correctLifecycleDocumentation(original) - .contains("When creating a topic, omit this property")); } @Test diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/ChatTopic.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/ChatTopic.java index 44ae5c266f95a..00edf74c378f2 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/ChatTopic.java +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/ChatTopic.java @@ -173,7 +173,6 @@ public ChatTopicState getState() { * @param state the state value to set. * @return the ChatTopic object itself. */ - @Generated public ChatTopic setState(ChatTopicState state) { this.state = state; this.updatedProperties.add("state"); diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/ChatServiceAsyncClientLiveTests.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/ChatServiceAsyncClientLiveTests.java deleted file mode 100644 index b52481df6b0ed..0000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/ChatServiceAsyncClientLiveTests.java +++ /dev/null @@ -1,185 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.messaging.webpubsub.chat; - -import com.azure.core.http.rest.PagedResponse; -import com.azure.core.test.TestMode; -import com.azure.messaging.webpubsub.chat.models.BuiltInChatRoles; -import com.azure.messaging.webpubsub.chat.models.ChatConversation; -import com.azure.messaging.webpubsub.chat.models.ChatMessage; -import com.azure.messaging.webpubsub.chat.models.ChatPermission; -import com.azure.messaging.webpubsub.chat.models.ChatRole; -import com.azure.messaging.webpubsub.chat.models.ChatRoom; -import com.azure.messaging.webpubsub.chat.models.ChatRoomMember; -import com.azure.messaging.webpubsub.chat.models.ChatUser; -import com.azure.messaging.webpubsub.chat.models.GetClientAccessTokenOptions; -import com.azure.messaging.webpubsub.chat.models.HumanChatUser; -import com.azure.messaging.webpubsub.chat.models.MessageContent; -import com.azure.messaging.webpubsub.chat.models.WebPubSubClientAccessToken; -import org.junit.jupiter.api.Test; - -import java.util.Collections; -import java.util.List; - -import static org.junit.jupiter.api.Assertions.assertArrayEquals; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class ChatServiceAsyncClientLiveTests extends ChatServiceClientTestBase { - @Test - public void canManageRolesAndPagination() { - String firstRoleName = testResourceNamer.randomName("user.java-async-test-", 55); - String secondRoleName = testResourceNamer.randomName("room.java-async-test-", 55); - - try { - ChatRole createdRole - = asyncClient - .createOrReplaceRole(firstRoleName, - new ChatRole(Collections.singletonList(ChatPermission.USER_CREATE_ROOM))) - .block(); - assertEquals(firstRoleName, createdRole.getName()); - assertEquals(firstRoleName, asyncClient.getRole(firstRoleName).block().getName()); - - asyncClient - .createOrReplaceRole(secondRoleName, - new ChatRole(Collections.singletonList(ChatPermission.ROOM_PUBLISH_MESSAGE))) - .block(); - List roles = asyncClient.listRoles().collectList().block(); - assertTrue(roles.stream().anyMatch(role -> firstRoleName.equals(role.getName()))); - - List> pages = asyncClient.listRoles().byPage().take(2).collectList().block(); - assertFalse(pages.isEmpty()); - PagedResponse firstPage = pages.get(0); - assertFalse(firstPage.getValue().isEmpty()); - if (firstPage.getContinuationToken() != null) { - assertEquals(2, pages.size()); - PagedResponse secondPage = pages.get(1); - assertFalse(secondPage.getValue().isEmpty()); - assertFalse(firstPage.getValue().get(0).getName().equals(secondPage.getValue().get(0).getName())); - } - } finally { - cleanup(() -> asyncClient.deleteRole(firstRoleName).block()); - cleanup(() -> asyncClient.deleteRole(secondRoleName).block()); - } - } - - @Test - public void canManageRoomsAndReadEmptyConversation() { - String roomId = testResourceNamer.randomName("java-async-test-room-", 55); - - try { - ChatRoom createdRoom - = asyncClient.createOrReplaceRoom(roomId, new ChatRoom("Java async test room")).block(); - assertEquals(roomId, createdRoom.getId()); - assertEquals("Java async test room", asyncClient.getRoom(roomId).block().getTitle()); - - ChatConversation conversation = asyncClient.getConversation(createdRoom.getDefaultConversation()).block(); - assertEquals(createdRoom.getDefaultConversation(), conversation.getId()); - assertEquals(roomId, conversation.getParentRoom()); - assertTrue(asyncClient.listMessages(conversation.getId()).collectList().block().isEmpty()); - assertTrue(asyncClient.listRoomMembers(roomId).collectList().block().isEmpty()); - } finally { - cleanup(() -> asyncClient.deleteRoom(roomId).block()); - } - } - - @Test - public void canManageUserRoomAndMember() { - String suffix = testResourceNamer.randomName("java", 20); - String userId = "java-async-test-user-" + suffix; - String roomId = "java-async-test-room-" + suffix; - - try { - ChatUser user = asyncClient - .createOrReplaceUser(userId, new HumanChatUser("Java test user", BuiltInChatRoles.USER_NORMAL)) - .block(); - assertEquals(userId, user.getId()); - assertEquals(userId, asyncClient.getUser(userId).block().getId()); - - ChatRoom room = asyncClient.createOrReplaceRoom(roomId, new ChatRoom("Java test room")).block(); - assertEquals(roomId, room.getId()); - - ChatRoomMember member = asyncClient - .createOrReplaceRoomMember(roomId, userId, new ChatRoomMember(BuiltInChatRoles.ROOM_MEMBER)) - .block(); - assertEquals(userId, member.getUserId()); - assertEquals(BuiltInChatRoles.ROOM_MEMBER, member.getRoleName()); - assertTrue(asyncClient.listRoomMembers(roomId) - .collectList() - .block() - .stream() - .anyMatch(item -> userId.equals(item.getUserId()))); - asyncClient.deleteRoomMember(roomId, userId).block(); - } finally { - cleanup(() -> asyncClient.deleteRoomMember(roomId, userId).block()); - cleanup(() -> asyncClient.deleteRoom(roomId).block()); - cleanup(() -> asyncClient.deleteUser(userId).block()); - } - } - - @Test - public void canListUpdateAndDeleteMessages() { - String suffix = testResourceNamer.randomName("java", 20); - String userId = "java-async-message-user-" + suffix; - String roomId = "java-async-message-room-" + suffix; - String messageText = "Java async live test message " + suffix; - String conversationId = null; - String messageId = null; - - try { - asyncClient - .createOrReplaceUser(userId, - new HumanChatUser("Java async message test user", BuiltInChatRoles.USER_NORMAL)) - .block(); - ChatRoom room - = asyncClient.createOrReplaceRoom(roomId, new ChatRoom("Java async message test room")).block(); - conversationId = room.getDefaultConversation(); - asyncClient.createOrReplaceRoomMember(roomId, userId, new ChatRoomMember(BuiltInChatRoles.ROOM_MEMBER)) - .block(); - - WebPubSubClientAccessToken accessToken - = entraAsyncClient.getClientAccessToken(new GetClientAccessTokenOptions().setUserId(userId)).block(); - assertNotNull(accessToken.getToken()); - assertNotNull(accessToken.getUrl()); - if (getTestMode() != TestMode.PLAYBACK) { - ChatMessageSeeder.sendTextMessage(accessToken.getUrl(), conversationId, messageText); - } - - ChatMessage createdMessage = asyncClient.listMessages(conversationId) - .filter(message -> userId.equals(message.getCreatedBy()) - && messageText.equals(message.getContent().getText())) - .blockFirst(); - assertNotNull(createdMessage); - messageId = createdMessage.getId(); - - ChatMessage updatedText - = asyncClient - .updateMessage(conversationId, messageId, - new ChatMessage().setCreatedBy(userId) - .setContent(MessageContent.fromText(messageText + " updated"))) - .block(); - assertEquals(messageText + " updated", updatedText.getContent().getText()); - - byte[] binary = new byte[] { 0, 1, 2, (byte) 254, (byte) 255 }; - ChatMessage updatedBinary - = asyncClient - .updateMessage(conversationId, messageId, - new ChatMessage().setCreatedBy(userId).setContent(MessageContent.fromBinary(binary))) - .block(); - assertArrayEquals(binary, updatedBinary.getContent().getBinary()); - asyncClient.deleteMessage(conversationId, messageId).block(); - } finally { - String finalConversationId = conversationId; - String finalMessageId = messageId; - if (finalConversationId != null && finalMessageId != null) { - cleanup(() -> asyncClient.deleteMessage(finalConversationId, finalMessageId).block()); - } - cleanup(() -> asyncClient.deleteRoomMember(roomId, userId).block()); - cleanup(() -> asyncClient.deleteRoom(roomId).block()); - cleanup(() -> asyncClient.deleteUser(userId).block()); - } - } -} diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/ChatServiceClientLiveTests.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/ChatServiceClientLiveTests.java index a0e4ba2691446..a7a527e1efcd3 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/ChatServiceClientLiveTests.java +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/ChatServiceClientLiveTests.java @@ -23,12 +23,10 @@ import com.azure.messaging.webpubsub.chat.models.HumanChatUser; import com.azure.messaging.webpubsub.chat.models.MessageContent; import com.azure.messaging.webpubsub.chat.models.WebPubSubClientAccessToken; -import org.junit.jupiter.api.Test; import reactor.core.publisher.Mono; import java.util.Arrays; import java.util.Collections; -import java.util.Iterator; import java.util.List; import java.util.stream.Collectors; import java.util.stream.StreamSupport; @@ -238,97 +236,145 @@ public void canListRoomsForUserWithPagination() { } } - @Test + @SyncAsyncTest public void canManageRolesWithConditionsAndPagination() { String firstRoleName = testResourceNamer.randomName("user.java-test-", 50); String secondRoleName = testResourceNamer.randomName("room.java-test-", 50); try { - ChatRole createdRole = client.createOrReplaceRole(firstRoleName, - new ChatRole(Collections.singletonList(ChatPermission.USER_CREATE_ROOM))); + ChatRole createdRole = execute( + () -> client.createOrReplaceRole(firstRoleName, + new ChatRole(Collections.singletonList(ChatPermission.USER_CREATE_ROOM))), + () -> asyncClient.createOrReplaceRole(firstRoleName, + new ChatRole(Collections.singletonList(ChatPermission.USER_CREATE_ROOM)))); assertEquals(firstRoleName, createdRole.getName()); - assertEquals(ChatPermission.USER_CREATE_ROOM, client.getRole(firstRoleName).getPermissions().get(0)); + ChatRole fetchedRole + = execute(() -> client.getRole(firstRoleName), () -> asyncClient.getRole(firstRoleName)); + assertEquals(firstRoleName, fetchedRole.getName()); + assertEquals(ChatPermission.USER_CREATE_ROOM, fetchedRole.getPermissions().get(0)); - ChatRole replacedRole = client.createOrReplaceRole(firstRoleName, - new ChatRole(Arrays.asList(ChatPermission.USER_CREATE_ROOM, ChatPermission.USER_FETCH_ALL_ROOMS)), - new MatchConditions().setIfMatch(createdRole.getEtag())); + ChatRole replacedRole + = execute( + () -> client.createOrReplaceRole(firstRoleName, + new ChatRole( + Arrays.asList(ChatPermission.USER_CREATE_ROOM, ChatPermission.USER_FETCH_ALL_ROOMS)), + new MatchConditions().setIfMatch(createdRole.getEtag())), + () -> asyncClient.createOrReplaceRole(firstRoleName, + new ChatRole( + Arrays.asList(ChatPermission.USER_CREATE_ROOM, ChatPermission.USER_FETCH_ALL_ROOMS)), + new MatchConditions().setIfMatch(createdRole.getEtag()))); assertFalse(createdRole.getEtag().equals(replacedRole.getEtag())); HttpResponseException staleEtag = assertThrows(HttpResponseException.class, - () -> client.createOrReplaceRole(firstRoleName, - new ChatRole(Collections.singletonList(ChatPermission.USER_CREATE_ROOM)), - new MatchConditions().setIfMatch(createdRole.getEtag()))); + () -> execute( + () -> client.createOrReplaceRole(firstRoleName, + new ChatRole(Collections.singletonList(ChatPermission.USER_CREATE_ROOM)), + new MatchConditions().setIfMatch(createdRole.getEtag())), + () -> asyncClient.createOrReplaceRole(firstRoleName, + new ChatRole(Collections.singletonList(ChatPermission.USER_CREATE_ROOM)), + new MatchConditions().setIfMatch(createdRole.getEtag())))); assertEquals(412, staleEtag.getResponse().getStatusCode()); - client.createOrReplaceRole(secondRoleName, - new ChatRole(Collections.singletonList(ChatPermission.ROOM_PUBLISH_MESSAGE)), - new MatchConditions().setIfNoneMatch("*")); - HttpResponseException alreadyExists = assertThrows(HttpResponseException.class, + execute( () -> client.createOrReplaceRole(secondRoleName, - new ChatRole(Collections.singletonList(ChatPermission.ROOM_HISTORY)), + new ChatRole(Collections.singletonList(ChatPermission.ROOM_PUBLISH_MESSAGE)), + new MatchConditions().setIfNoneMatch("*")), + () -> asyncClient.createOrReplaceRole(secondRoleName, + new ChatRole(Collections.singletonList(ChatPermission.ROOM_PUBLISH_MESSAGE)), new MatchConditions().setIfNoneMatch("*"))); + HttpResponseException alreadyExists = assertThrows(HttpResponseException.class, + () -> execute( + () -> client.createOrReplaceRole(secondRoleName, + new ChatRole(Collections.singletonList(ChatPermission.ROOM_HISTORY)), + new MatchConditions().setIfNoneMatch("*")), + () -> asyncClient.createOrReplaceRole(secondRoleName, + new ChatRole(Collections.singletonList(ChatPermission.ROOM_HISTORY)), + new MatchConditions().setIfNoneMatch("*")))); assertEquals(412, alreadyExists.getResponse().getStatusCode()); - assertTrue(client.listRoles().stream().anyMatch(role -> firstRoleName.equals(role.getName()))); - Iterator> pages = client.listRoles().iterableByPage(1).iterator(); - PagedResponse firstPage = pages.next(); + assertTrue(execute(() -> client.listRoles().stream().anyMatch(role -> firstRoleName.equals(role.getName())), + () -> asyncClient.listRoles().any(role -> firstRoleName.equals(role.getName())))); + List> pages + = execute(() -> StreamSupport.stream(client.listRoles().iterableByPage(1).spliterator(), false) + .limit(2) + .collect(Collectors.toList()), () -> asyncClient.listRoles().byPage(1).take(2).collectList()); + assertFalse(pages.isEmpty()); + PagedResponse firstPage = pages.get(0); assertFalse(firstPage.getValue().isEmpty()); if (firstPage.getContinuationToken() != null) { - assertTrue(pages.hasNext()); - PagedResponse secondPage = pages.next(); + assertEquals(2, pages.size()); + PagedResponse secondPage = pages.get(1); assertFalse(secondPage.getValue().isEmpty()); assertFalse(firstPage.getValue().get(0).getName().equals(secondPage.getValue().get(0).getName())); } } finally { - cleanup(() -> client.deleteRole(firstRoleName)); - cleanup(() -> client.deleteRole(secondRoleName)); + cleanup(() -> execute(() -> client.deleteRole(firstRoleName), () -> asyncClient.deleteRole(firstRoleName))); + cleanup( + () -> execute(() -> client.deleteRole(secondRoleName), () -> asyncClient.deleteRole(secondRoleName))); } } - @Test + @SyncAsyncTest public void canManageRoomsAndReadEmptyConversation() { String roomId = testResourceNamer.randomName("java-test-room-", 50); try { - ChatRoom createdRoom = client.createOrReplaceRoom(roomId, new ChatRoom("Java test room")); + ChatRoom createdRoom = execute(() -> client.createOrReplaceRoom(roomId, new ChatRoom("Java test room")), + () -> asyncClient.createOrReplaceRoom(roomId, new ChatRoom("Java test room"))); assertEquals(roomId, createdRoom.getId()); - assertEquals("Java test room", client.getRoom(roomId).getTitle()); + assertEquals("Java test room", + execute(() -> client.getRoom(roomId), () -> asyncClient.getRoom(roomId)).getTitle()); - ChatConversation conversation = client.getConversation(createdRoom.getDefaultConversation()); + ChatConversation conversation = execute(() -> client.getConversation(createdRoom.getDefaultConversation()), + () -> asyncClient.getConversation(createdRoom.getDefaultConversation())); assertEquals(createdRoom.getDefaultConversation(), conversation.getId()); assertEquals(roomId, conversation.getParentRoom()); - assertFalse(client.listMessages(conversation.getId()).stream().findAny().isPresent()); - assertFalse(client.listRoomMembers(roomId).stream().findAny().isPresent()); + assertFalse(execute(() -> client.listMessages(conversation.getId()).stream().findAny().isPresent(), + () -> asyncClient.listMessages(conversation.getId()).hasElements())); + assertFalse(execute(() -> client.listRoomMembers(roomId).stream().findAny().isPresent(), + () -> asyncClient.listRoomMembers(roomId).hasElements())); } finally { - cleanup(() -> client.deleteRoom(roomId)); + cleanup(() -> execute(() -> client.deleteRoom(roomId), () -> asyncClient.deleteRoom(roomId))); } } - @Test + @SyncAsyncTest public void canManageUsersAndRoomMembers() { String suffix = testResourceNamer.randomName("java", 20); String userId = "java-test-user-" + suffix; String roomId = "java-test-room-" + suffix; try { - ChatUser createdUser - = client.createOrReplaceUser(userId, new HumanChatUser("Java test user", BuiltInChatRoles.USER_NORMAL)); + ChatUser createdUser = execute( + () -> client.createOrReplaceUser(userId, + new HumanChatUser("Java test user", BuiltInChatRoles.USER_NORMAL)), + () -> asyncClient.createOrReplaceUser(userId, + new HumanChatUser("Java test user", BuiltInChatRoles.USER_NORMAL))); assertEquals(userId, createdUser.getId()); - assertEquals(userId, client.getUser(userId).getId()); + assertEquals(userId, execute(() -> client.getUser(userId), () -> asyncClient.getUser(userId)).getId()); - client.createOrReplaceRoom(roomId, new ChatRoom("Java member test room")); - ChatRoomMember member - = client.createOrReplaceRoomMember(roomId, userId, new ChatRoomMember(BuiltInChatRoles.ROOM_MEMBER)); + ChatRoom room = execute(() -> client.createOrReplaceRoom(roomId, new ChatRoom("Java member test room")), + () -> asyncClient.createOrReplaceRoom(roomId, new ChatRoom("Java member test room"))); + assertEquals(roomId, room.getId()); + ChatRoomMember member = execute( + () -> client.createOrReplaceRoomMember(roomId, userId, + new ChatRoomMember(BuiltInChatRoles.ROOM_MEMBER)), + () -> asyncClient.createOrReplaceRoomMember(roomId, userId, + new ChatRoomMember(BuiltInChatRoles.ROOM_MEMBER))); assertEquals(userId, member.getUserId()); - assertTrue(client.listRoomMembers(roomId).stream().anyMatch(item -> userId.equals(item.getUserId()))); - client.deleteRoomMember(roomId, userId); + assertEquals(BuiltInChatRoles.ROOM_MEMBER, member.getRoleName()); + assertTrue( + execute(() -> client.listRoomMembers(roomId).stream().anyMatch(item -> userId.equals(item.getUserId())), + () -> asyncClient.listRoomMembers(roomId).any(item -> userId.equals(item.getUserId())))); + execute(() -> client.deleteRoomMember(roomId, userId), () -> asyncClient.deleteRoomMember(roomId, userId)); } finally { - cleanup(() -> client.deleteRoomMember(roomId, userId)); - cleanup(() -> client.deleteRoom(roomId)); - cleanup(() -> client.deleteUser(userId)); + cleanup(() -> execute(() -> client.deleteRoomMember(roomId, userId), + () -> asyncClient.deleteRoomMember(roomId, userId))); + cleanup(() -> execute(() -> client.deleteRoom(roomId), () -> asyncClient.deleteRoom(roomId))); + cleanup(() -> execute(() -> client.deleteUser(userId), () -> asyncClient.deleteUser(userId))); } } - @Test + @SyncAsyncTest public void canListUpdateAndDeleteMessages() { String suffix = testResourceNamer.randomName("java", 20); String userId = "java-test-message-user-" + suffix; @@ -338,46 +384,74 @@ public void canListUpdateAndDeleteMessages() { String messageId = null; try { - client.createOrReplaceUser(userId, - new HumanChatUser("Java message test user", BuiltInChatRoles.USER_NORMAL)); - ChatRoom room = client.createOrReplaceRoom(roomId, new ChatRoom("Java message test room")); + execute( + () -> client.createOrReplaceUser(userId, + new HumanChatUser("Java message test user", BuiltInChatRoles.USER_NORMAL)), + () -> asyncClient.createOrReplaceUser(userId, + new HumanChatUser("Java message test user", BuiltInChatRoles.USER_NORMAL))); + ChatRoom room = execute(() -> client.createOrReplaceRoom(roomId, new ChatRoom("Java message test room")), + () -> asyncClient.createOrReplaceRoom(roomId, new ChatRoom("Java message test room"))); conversationId = room.getDefaultConversation(); - client.createOrReplaceRoomMember(roomId, userId, new ChatRoomMember(BuiltInChatRoles.ROOM_MEMBER)); + execute( + () -> client.createOrReplaceRoomMember(roomId, userId, + new ChatRoomMember(BuiltInChatRoles.ROOM_MEMBER)), + () -> asyncClient.createOrReplaceRoomMember(roomId, userId, + new ChatRoomMember(BuiltInChatRoles.ROOM_MEMBER))); WebPubSubClientAccessToken accessToken - = entraClient.getClientAccessToken(new GetClientAccessTokenOptions().setUserId(userId)); + = execute(() -> entraClient.getClientAccessToken(new GetClientAccessTokenOptions().setUserId(userId)), + () -> entraAsyncClient.getClientAccessToken(new GetClientAccessTokenOptions().setUserId(userId))); assertNotNull(accessToken.getToken()); assertNotNull(accessToken.getUrl()); if (getTestMode() != TestMode.PLAYBACK) { ChatMessageSeeder.sendTextMessage(accessToken.getUrl(), conversationId, messageText); } - ChatMessage createdMessage = client.listMessages(conversationId) - .stream() - .filter(message -> userId.equals(message.getCreatedBy()) - && messageText.equals(message.getContent().getText())) - .findFirst() - .orElseThrow(() -> new AssertionError("The seeded Chat message was not found.")); + String currentConversationId = conversationId; + ChatMessage createdMessage = execute( + () -> client.listMessages(currentConversationId) + .stream() + .filter(message -> userId.equals(message.getCreatedBy()) + && messageText.equals(message.getContent().getText())) + .findFirst() + .orElseThrow(() -> new AssertionError("The seeded Chat message was not found.")), + () -> asyncClient.listMessages(currentConversationId) + .filter(message -> userId.equals(message.getCreatedBy()) + && messageText.equals(message.getContent().getText())) + .next()); + assertNotNull(createdMessage); messageId = createdMessage.getId(); - - ChatMessage updatedText = client.updateMessage(conversationId, messageId, - new ChatMessage().setCreatedBy(userId).setContent(MessageContent.fromText(messageText + " updated"))); + String currentMessageId = messageId; + + ChatMessage updatedText = execute( + () -> client.updateMessage(currentConversationId, currentMessageId, + new ChatMessage().setCreatedBy(userId) + .setContent(MessageContent.fromText(messageText + " updated"))), + () -> asyncClient.updateMessage(currentConversationId, currentMessageId, + new ChatMessage().setCreatedBy(userId) + .setContent(MessageContent.fromText(messageText + " updated")))); assertEquals(messageText + " updated", updatedText.getContent().getText()); byte[] binary = new byte[] { 0, 1, 2, (byte) 254, (byte) 255 }; - ChatMessage updatedBinary = client.updateMessage(conversationId, messageId, - new ChatMessage().setCreatedBy(userId).setContent(MessageContent.fromBinary(binary))); + ChatMessage updatedBinary = execute( + () -> client.updateMessage(currentConversationId, currentMessageId, + new ChatMessage().setCreatedBy(userId).setContent(MessageContent.fromBinary(binary))), + () -> asyncClient.updateMessage(currentConversationId, currentMessageId, + new ChatMessage().setCreatedBy(userId).setContent(MessageContent.fromBinary(binary)))); assertArrayEquals(binary, updatedBinary.getContent().getBinary()); - client.deleteMessage(conversationId, messageId); + execute(() -> client.deleteMessage(currentConversationId, currentMessageId), + () -> asyncClient.deleteMessage(currentConversationId, currentMessageId)); } finally { String finalConversationId = conversationId; String finalMessageId = messageId; if (finalConversationId != null && finalMessageId != null) { - cleanup(() -> client.deleteMessage(finalConversationId, finalMessageId)); + cleanup(() -> execute(() -> client.deleteMessage(finalConversationId, finalMessageId), + () -> asyncClient.deleteMessage(finalConversationId, finalMessageId))); } - cleanup(() -> client.deleteRoomMember(roomId, userId)); - cleanup(() -> client.deleteRoom(roomId)); - cleanup(() -> client.deleteUser(userId)); + cleanup(() -> execute(() -> client.deleteRoomMember(roomId, userId), + () -> asyncClient.deleteRoomMember(roomId, userId))); + cleanup(() -> execute(() -> client.deleteRoom(roomId), () -> asyncClient.deleteRoom(roomId))); + cleanup(() -> execute(() -> client.deleteUser(userId), () -> asyncClient.deleteUser(userId))); } } } From 072734b5efe747c8004a0c33724cf5a8da7591b4 Mon Sep 17 00:00:00 2001 From: Zitong Yang Date: Wed, 28 Oct 2026 16:21:28 +1100 Subject: [PATCH 10/18] Support local user identities in Chat test resource provisioning Restore the configurable tester principal type and document the local user-authentication override while preserving service-principal defaults for CI. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .../azure-messaging-webpubsub-chat/README.md | 12 ++++++++++++ .../test-resources.bicep | 10 +++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/README.md b/sdk/webpubsub/azure-messaging-webpubsub-chat/README.md index c02724239fb46..b919dcdbbfe3c 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/README.md +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/README.md @@ -360,6 +360,18 @@ This project welcomes contributions and suggestions. See the [contributing guide This project has adopted the [Microsoft Open Source Code of Conduct][code_of_conduct]. For more information, see the [Code of Conduct FAQ][code_of_conduct_faq] or contact opencode@microsoft.com with questions or comments. +### Running live tests locally + +Playback tests do not require Azure resources. To provision resources for live tests, the shared test-resource script uses your signed-in user by default. From the repository root, specify the matching principal type so the Chat data-plane roles are assigned to that user: + +```powershell +.\eng\common\TestResources\New-TestResources.ps1 ` + -ServiceDirectory webpubsub\azure-messaging-webpubsub-chat ` + -AdditionalParameters @{ testPrincipalType = 'User' } +``` + +CI and local provisioning with `-ServicePrincipalAuth` use the default `ServicePrincipal` type; omit the `testPrincipalType` override for those runs. This parameter is only needed when provisioning resources, not when running tests against an existing deployment. + [source_code]: https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/webpubsub/azure-messaging-webpubsub-chat/src [package]: https://central.sonatype.com/artifact/com.azure/azure-messaging-webpubsub-chat diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/test-resources.bicep b/sdk/webpubsub/azure-messaging-webpubsub-chat/test-resources.bicep index 28932f949d412..24d50a1982738 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/test-resources.bicep +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/test-resources.bicep @@ -1,9 +1,13 @@ @description('The base resource name.') param baseName string = resourceGroup().name -@description('This is the object id of the service principal used to run tests.') +@description('Object ID of the identity used to run tests.') param testApplicationOid string +@description('Principal type of the identity used to run tests.') +@allowed([ 'ServicePrincipal', 'User' ]) +param testPrincipalType string = 'ServicePrincipal' + @description('Location of the resource.') param location string = resourceGroup().location @@ -123,7 +127,7 @@ resource webPubSubOwnerRoleAssignment 'Microsoft.Authorization/roleAssignments@2 properties: { roleDefinitionId: webPubSubOwnerRoleId principalId: testApplicationOid - principalType: 'ServicePrincipal' + principalType: testPrincipalType } } @@ -133,7 +137,7 @@ resource webPubSubOperatorRoleAssignment 'Microsoft.Authorization/roleAssignment properties: { roleDefinitionId: webPubSubOperatorRoleId principalId: testApplicationOid - principalType: 'ServicePrincipal' + principalType: testPrincipalType } } From 8195d396d965b696d537c4929974fe189b6ae7f6 Mon Sep 17 00:00:00 2001 From: Zitong Yang Date: Wed, 28 Oct 2026 17:10:45 +1100 Subject: [PATCH 11/18] Remove developer-only test setup from Chat README Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .../azure-messaging-webpubsub-chat/README.md | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/README.md b/sdk/webpubsub/azure-messaging-webpubsub-chat/README.md index b919dcdbbfe3c..c02724239fb46 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/README.md +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/README.md @@ -360,18 +360,6 @@ This project welcomes contributions and suggestions. See the [contributing guide This project has adopted the [Microsoft Open Source Code of Conduct][code_of_conduct]. For more information, see the [Code of Conduct FAQ][code_of_conduct_faq] or contact opencode@microsoft.com with questions or comments. -### Running live tests locally - -Playback tests do not require Azure resources. To provision resources for live tests, the shared test-resource script uses your signed-in user by default. From the repository root, specify the matching principal type so the Chat data-plane roles are assigned to that user: - -```powershell -.\eng\common\TestResources\New-TestResources.ps1 ` - -ServiceDirectory webpubsub\azure-messaging-webpubsub-chat ` - -AdditionalParameters @{ testPrincipalType = 'User' } -``` - -CI and local provisioning with `-ServicePrincipalAuth` use the default `ServicePrincipal` type; omit the `testPrincipalType` override for those runs. This parameter is only needed when provisioning resources, not when running tests against an existing deployment. - [source_code]: https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/webpubsub/azure-messaging-webpubsub-chat/src [package]: https://central.sonatype.com/artifact/com.azure/azure-messaging-webpubsub-chat From e5671c4461636cce0a0b6ea71adfecb2a20d187e Mon Sep 17 00:00:00 2001 From: Zitong Yang Date: Wed, 28 Oct 2026 22:52:25 -0700 Subject: [PATCH 12/18] Address Web PubSub Chat APIView feedback Rename client access token options and resource parameters, expose conversation roomId with its existing wire name, clarify paging and content documentation, and pin the shared TypeSpec changes. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .../CHANGELOG.md | 4 + .../azure-messaging-webpubsub-chat/README.md | 6 +- .../main/java/WebPubSubChatCustomization.java | 2 + .../chat/WebPubSubChatServiceAsyncClient.java | 180 ++++++++++-------- .../chat/WebPubSubChatServiceClient.java | 178 +++++++++-------- .../WebPubSubClientAccessTokenFactory.java | 8 +- .../WebPubSubChatServiceClientImpl.java | 128 +++++++------ .../chat/models/ChatConversation.java | 46 ++--- ...ons.java => ClientAccessTokenOptions.java} | 22 ++- .../webpubsub/chat/models/MessageContent.java | 2 + ...ure-messaging-webpubsub-chat_metadata.json | 2 +- .../webpubsub/chat/WebPubSubChatSamples.java | 4 +- .../chat/ChatServiceClientLiveTests.java | 8 +- .../webpubsub/chat/MessageContentTests.java | 29 +++ .../WebPubSubChatClientAccessTokenTests.java | 22 +-- .../chat/models/ChatConversationTests.java | 23 +++ .../tsp-location.yaml | 2 +- 17 files changed, 392 insertions(+), 274 deletions(-) rename sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/{GetClientAccessTokenOptions.java => ClientAccessTokenOptions.java} (53%) create mode 100644 sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/models/ChatConversationTests.java diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/CHANGELOG.md b/sdk/webpubsub/azure-messaging-webpubsub-chat/CHANGELOG.md index a11e3581047b0..e179f4dfee96a 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/CHANGELOG.md +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/CHANGELOG.md @@ -12,6 +12,8 @@ ### Breaking Changes - Replaced the public `MessageContent` constructor and `setText`/`setBinary` methods with `MessageContent.fromText` and `MessageContent.fromBinary`. Each instance contains exactly one non-null representation; empty text and binary payloads remain supported. +- Renamed `GetClientAccessTokenOptions` to `ClientAccessTokenOptions`. +- Renamed `ChatConversation.getParentRoom()` to `getRoomId()`. The JSON property remains `parentRoom`. ### Bugs Fixed @@ -20,6 +22,8 @@ ### Other Changes +- Renamed request body parameters from `resource` to `role`, `room`, `member`, `user`, `topic`, or `message` to match their operations. +- Clarified message-ID-based descending pagination, text versus binary message content, and client access token generation. - Verified all existing and new operations end to end with `2026-08-01-preview` in Central US EUAP; removed the temporary server routing workaround and restored the complete live/playback suite. - Enabled all typed asynchronous page-size regression cases and removed the temporary protocol paging workaround from tests and samples. diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/README.md b/sdk/webpubsub/azure-messaging-webpubsub-chat/README.md index c02724239fb46..4439b64b74820 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/README.md +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/README.md @@ -137,10 +137,14 @@ renamed, archived, and soft deleted independently of the room's default conversa ```java readme-sample-getChatClientAccessToken WebPubSubClientAccessToken accessToken = client.getClientAccessToken( - new GetClientAccessTokenOptions().setUserId("alice").setExpiresAfter(Duration.ofHours(1))); + new ClientAccessTokenOptions().setUserId("alice").setExpiresAfter(Duration.ofHours(1))); String clientConnectionUrl = accessToken.getUrl(); ``` +`ClientAccessTokenOptions` specifies the user ID and token lifetime (one hour by default). +With an access key or connection string, the SDK signs the token locally. With Microsoft Entra ID, +the SDK requests the token from the service. + The returned URL contains an access token. Send it only to the intended client, and do not log or persist it in production. ### Work with built-in values diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/src/main/java/WebPubSubChatCustomization.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/src/main/java/WebPubSubChatCustomization.java index 4dffe6cc8359f..4d9c93b969687 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/src/main/java/WebPubSubChatCustomization.java +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/src/main/java/WebPubSubChatCustomization.java @@ -129,6 +129,8 @@ static void customizeMessageContent(CompilationUnit ast) { } model.setJavadocComment("Message content containing exactly one of text or binary data.\n" + "Use {@link #fromText(String)} or {@link #fromBinary(byte[])} to create content.\n" + + "Text and binary are independent content types, not alternate encodings of the same value.\n" + + "Binary data is base64 encoded on the wire. No conversion between text and binary is performed.\n" + "The getter for the unselected representation returns {@code null}."); model.getFieldByName("updatedProperties").ifPresent(field -> field.remove()); model.getMethodsByName("setText").forEach(method -> method.remove()); diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceAsyncClient.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceAsyncClient.java index 25b2096b1057e..189f0e64f165e 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceAsyncClient.java +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceAsyncClient.java @@ -31,7 +31,7 @@ import com.azure.messaging.webpubsub.chat.models.ChatTopic; import com.azure.messaging.webpubsub.chat.models.ChatUser; import com.azure.messaging.webpubsub.chat.models.ChatUserRoom; -import com.azure.messaging.webpubsub.chat.models.GetClientAccessTokenOptions; +import com.azure.messaging.webpubsub.chat.models.ClientAccessTokenOptions; import com.azure.messaging.webpubsub.chat.models.WebPubSubClientAccessToken; import java.util.stream.Collectors; import reactor.core.publisher.Flux; @@ -87,6 +87,10 @@ public Mono> getConversationWithResponse(String conversatio /** * Query messages in a conversation from latest to earliest. + * + * Query messages in a conversation from latest to earliest. + * Message IDs are used as pagination cursors. Follow the response nextLink, + * which contains the message ID cursor, to retrieve the next page. *

Query Parameters

*
* @@ -209,7 +213,7 @@ public Mono> deleteMessageWithResponse(String conversationId, Str * * @param conversationId Conversation identifier. * @param messageId Message identifier. - * @param resource The resource instance. + * @param message The resource instance. * @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. @@ -220,8 +224,8 @@ public Mono> deleteMessageWithResponse(String conversationId, Str @Generated @ServiceMethod(returns = ReturnType.SINGLE) public Mono> updateMessageWithResponse(String conversationId, String messageId, - BinaryData resource, RequestOptions requestOptions) { - return this.serviceClient.updateMessageWithResponseAsync(conversationId, messageId, resource, requestOptions); + BinaryData message, RequestOptions requestOptions) { + return this.serviceClient.updateMessageWithResponseAsync(conversationId, messageId, message, requestOptions); } /** @@ -337,7 +341,7 @@ public Mono> getRoleWithResponse(String roleName, RequestOp *
Query Parameters
* * @param roleName Role name. Must start with 'user.' or 'room.' prefix. - * @param resource The resource instance. + * @param role The resource instance. * @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. @@ -350,9 +354,9 @@ public Mono> getRoleWithResponse(String roleName, RequestOp */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> createOrReplaceRoleWithResponse(String roleName, BinaryData resource, + public Mono> createOrReplaceRoleWithResponse(String roleName, BinaryData role, RequestOptions requestOptions) { - return this.serviceClient.createOrReplaceRoleWithResponseAsync(roleName, resource, requestOptions); + return this.serviceClient.createOrReplaceRoleWithResponseAsync(roleName, role, requestOptions); } /** @@ -427,7 +431,7 @@ public Mono> deleteRoleWithResponse(String roleName, RequestOptio * * * @param roomId Room identifier. - * @param resource The resource instance. + * @param room The resource instance. * @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. @@ -437,9 +441,9 @@ public Mono> deleteRoleWithResponse(String roleName, RequestOptio */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> createOrReplaceRoomWithResponse(String roomId, BinaryData resource, + public Mono> createOrReplaceRoomWithResponse(String roomId, BinaryData room, RequestOptions requestOptions) { - return this.serviceClient.createOrReplaceRoomWithResponseAsync(roomId, resource, requestOptions); + return this.serviceClient.createOrReplaceRoomWithResponseAsync(roomId, room, requestOptions); } /** @@ -577,7 +581,7 @@ public PagedFlux listRoomMembers(String roomId, RequestOptions reque * * @param roomId Room identifier. * @param userId User ID of the member. - * @param resource The resource instance. + * @param member The resource instance. * @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. @@ -588,8 +592,8 @@ public PagedFlux listRoomMembers(String roomId, RequestOptions reque @Generated @ServiceMethod(returns = ReturnType.SINGLE) public Mono> createOrReplaceRoomMemberWithResponse(String roomId, String userId, - BinaryData resource, RequestOptions requestOptions) { - return this.serviceClient.createOrReplaceRoomMemberWithResponseAsync(roomId, userId, resource, requestOptions); + BinaryData member, RequestOptions requestOptions) { + return this.serviceClient.createOrReplaceRoomMemberWithResponseAsync(roomId, userId, member, requestOptions); } /** @@ -702,7 +706,7 @@ public Mono> getUserWithResponse(String userId, RequestOpti * * * @param userId User identifier. - * @param resource The resource instance. + * @param user The resource instance. * @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. @@ -713,9 +717,9 @@ public Mono> getUserWithResponse(String userId, RequestOpti */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> createOrReplaceUserWithResponse(String userId, BinaryData resource, + public Mono> createOrReplaceUserWithResponse(String userId, BinaryData user, RequestOptions requestOptions) { - return this.serviceClient.createOrReplaceUserWithResponseAsync(userId, resource, requestOptions); + return this.serviceClient.createOrReplaceUserWithResponseAsync(userId, user, requestOptions); } /** @@ -769,6 +773,10 @@ public Mono getConversation(String conversationId) { /** * Query messages in a conversation from latest to earliest. * + * Query messages in a conversation from latest to earliest. + * Message IDs are used as pagination cursors. Follow the response nextLink, + * which contains the message ID cursor, to retrieve the next page. + * * @param conversationId Conversation identifier. * @param latestMessageId Latest message ID (exclusive) for pagination. * @param earliestMessageId Earliest message ID (exclusive) for pagination. @@ -817,6 +825,10 @@ public PagedFlux listMessages(String conversationId, String latestM /** * Query messages in a conversation from latest to earliest. * + * Query messages in a conversation from latest to earliest. + * Message IDs are used as pagination cursors. Follow the response nextLink, + * which contains the message ID cursor, to retrieve the next page. + * * @param conversationId Conversation identifier. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. @@ -909,7 +921,7 @@ public Mono deleteMessage(String conversationId, String messageId) { * * @param conversationId Conversation identifier. * @param messageId Message identifier. - * @param resource The resource instance. + * @param message The resource instance. * @param matchConditions Specifies HTTP options for conditional requests. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. @@ -921,7 +933,7 @@ public Mono deleteMessage(String conversationId, String messageId) { */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Mono updateMessage(String conversationId, String messageId, ChatMessage resource, + public Mono updateMessage(String conversationId, String messageId, ChatMessage message, MatchConditions matchConditions) { // Generated convenience method for updateMessageWithResponse RequestOptions requestOptions = new RequestOptions(); @@ -933,12 +945,12 @@ public Mono updateMessage(String conversationId, String messageId, if (ifNoneMatch != null) { requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); } - JsonMergePatchHelper.getChatMessageAccessor().prepareModelForJsonMergePatch(resource, true); - BinaryData resourceInBinaryData = BinaryData.fromObject(resource); + JsonMergePatchHelper.getChatMessageAccessor().prepareModelForJsonMergePatch(message, true); + BinaryData messageInBinaryData = BinaryData.fromObject(message); // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. - resourceInBinaryData.getLength(); - JsonMergePatchHelper.getChatMessageAccessor().prepareModelForJsonMergePatch(resource, false); - return updateMessageWithResponse(conversationId, messageId, resourceInBinaryData, requestOptions) + messageInBinaryData.getLength(); + JsonMergePatchHelper.getChatMessageAccessor().prepareModelForJsonMergePatch(message, false); + return updateMessageWithResponse(conversationId, messageId, messageInBinaryData, requestOptions) .flatMap(FluxUtil::toMono) .map(protocolMethodData -> protocolMethodData.toObject(ChatMessage.class)); } @@ -948,7 +960,7 @@ public Mono updateMessage(String conversationId, String messageId, * * @param conversationId Conversation identifier. * @param messageId Message identifier. - * @param resource The resource instance. + * @param message The resource instance. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. @@ -959,15 +971,15 @@ public Mono updateMessage(String conversationId, String messageId, */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Mono updateMessage(String conversationId, String messageId, ChatMessage resource) { + public Mono updateMessage(String conversationId, String messageId, ChatMessage message) { // Generated convenience method for updateMessageWithResponse RequestOptions requestOptions = new RequestOptions(); - JsonMergePatchHelper.getChatMessageAccessor().prepareModelForJsonMergePatch(resource, true); - BinaryData resourceInBinaryData = BinaryData.fromObject(resource); + JsonMergePatchHelper.getChatMessageAccessor().prepareModelForJsonMergePatch(message, true); + BinaryData messageInBinaryData = BinaryData.fromObject(message); // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. - resourceInBinaryData.getLength(); - JsonMergePatchHelper.getChatMessageAccessor().prepareModelForJsonMergePatch(resource, false); - return updateMessageWithResponse(conversationId, messageId, resourceInBinaryData, requestOptions) + messageInBinaryData.getLength(); + JsonMergePatchHelper.getChatMessageAccessor().prepareModelForJsonMergePatch(message, false); + return updateMessageWithResponse(conversationId, messageId, messageInBinaryData, requestOptions) .flatMap(FluxUtil::toMono) .map(protocolMethodData -> protocolMethodData.toObject(ChatMessage.class)); } @@ -1076,7 +1088,7 @@ public Mono getRole(String roleName) { * Create or replace a role. * * @param roleName Role name. Must start with 'user.' or 'room.' prefix. - * @param resource The resource instance. + * @param role The resource instance. * @param matchConditions Specifies HTTP options for conditional requests. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. @@ -1091,7 +1103,7 @@ public Mono getRole(String roleName) { */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Mono createOrReplaceRole(String roleName, ChatRole resource, MatchConditions matchConditions) { + public Mono createOrReplaceRole(String roleName, ChatRole role, MatchConditions matchConditions) { // Generated convenience method for createOrReplaceRoleWithResponse RequestOptions requestOptions = new RequestOptions(); String ifMatch = matchConditions == null ? null : matchConditions.getIfMatch(); @@ -1102,7 +1114,7 @@ public Mono createOrReplaceRole(String roleName, ChatRole resource, Ma if (ifNoneMatch != null) { requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); } - return createOrReplaceRoleWithResponse(roleName, BinaryData.fromObject(resource), requestOptions) + return createOrReplaceRoleWithResponse(roleName, BinaryData.fromObject(role), requestOptions) .flatMap(FluxUtil::toMono) .map(protocolMethodData -> protocolMethodData.toObject(ChatRole.class)); } @@ -1111,7 +1123,7 @@ public Mono createOrReplaceRole(String roleName, ChatRole resource, Ma * Create or replace a role. * * @param roleName Role name. Must start with 'user.' or 'room.' prefix. - * @param resource The resource instance. + * @param role The resource instance. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. @@ -1125,10 +1137,10 @@ public Mono createOrReplaceRole(String roleName, ChatRole resource, Ma */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Mono createOrReplaceRole(String roleName, ChatRole resource) { + public Mono createOrReplaceRole(String roleName, ChatRole role) { // Generated convenience method for createOrReplaceRoleWithResponse RequestOptions requestOptions = new RequestOptions(); - return createOrReplaceRoleWithResponse(roleName, BinaryData.fromObject(resource), requestOptions) + return createOrReplaceRoleWithResponse(roleName, BinaryData.fromObject(role), requestOptions) .flatMap(FluxUtil::toMono) .map(protocolMethodData -> protocolMethodData.toObject(ChatRole.class)); } @@ -1188,7 +1200,7 @@ public Mono deleteRole(String roleName) { * Create or replace a room with a client-specified ID. * * @param roomId Room identifier. - * @param resource The resource instance. + * @param room The resource instance. * @param matchConditions Specifies HTTP options for conditional requests. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. @@ -1200,7 +1212,7 @@ public Mono deleteRole(String roleName) { */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Mono createOrReplaceRoom(String roomId, ChatRoom resource, MatchConditions matchConditions) { + public Mono createOrReplaceRoom(String roomId, ChatRoom room, MatchConditions matchConditions) { // Generated convenience method for createOrReplaceRoomWithResponse RequestOptions requestOptions = new RequestOptions(); String ifMatch = matchConditions == null ? null : matchConditions.getIfMatch(); @@ -1211,7 +1223,7 @@ public Mono createOrReplaceRoom(String roomId, ChatRoom resource, Matc if (ifNoneMatch != null) { requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); } - return createOrReplaceRoomWithResponse(roomId, BinaryData.fromObject(resource), requestOptions) + return createOrReplaceRoomWithResponse(roomId, BinaryData.fromObject(room), requestOptions) .flatMap(FluxUtil::toMono) .map(protocolMethodData -> protocolMethodData.toObject(ChatRoom.class)); } @@ -1222,7 +1234,7 @@ public Mono createOrReplaceRoom(String roomId, ChatRoom resource, Matc * Create or replace a room with a client-specified ID. * * @param roomId Room identifier. - * @param resource The resource instance. + * @param room The resource instance. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. @@ -1233,10 +1245,10 @@ public Mono createOrReplaceRoom(String roomId, ChatRoom resource, Matc */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Mono createOrReplaceRoom(String roomId, ChatRoom resource) { + public Mono createOrReplaceRoom(String roomId, ChatRoom room) { // Generated convenience method for createOrReplaceRoomWithResponse RequestOptions requestOptions = new RequestOptions(); - return createOrReplaceRoomWithResponse(roomId, BinaryData.fromObject(resource), requestOptions) + return createOrReplaceRoomWithResponse(roomId, BinaryData.fromObject(room), requestOptions) .flatMap(FluxUtil::toMono) .map(protocolMethodData -> protocolMethodData.toObject(ChatRoom.class)); } @@ -1398,7 +1410,7 @@ public PagedFlux listRoomMembers(String roomId) { * * @param roomId Room identifier. * @param userId User ID of the member. - * @param resource The resource instance. + * @param member The resource instance. * @param matchConditions Specifies HTTP options for conditional requests. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. @@ -1410,7 +1422,7 @@ public PagedFlux listRoomMembers(String roomId) { */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Mono createOrReplaceRoomMember(String roomId, String userId, ChatRoomMember resource, + public Mono createOrReplaceRoomMember(String roomId, String userId, ChatRoomMember member, MatchConditions matchConditions) { // Generated convenience method for createOrReplaceRoomMemberWithResponse RequestOptions requestOptions = new RequestOptions(); @@ -1422,7 +1434,7 @@ public Mono createOrReplaceRoomMember(String roomId, String user if (ifNoneMatch != null) { requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); } - return createOrReplaceRoomMemberWithResponse(roomId, userId, BinaryData.fromObject(resource), requestOptions) + return createOrReplaceRoomMemberWithResponse(roomId, userId, BinaryData.fromObject(member), requestOptions) .flatMap(FluxUtil::toMono) .map(protocolMethodData -> protocolMethodData.toObject(ChatRoomMember.class)); } @@ -1432,7 +1444,7 @@ public Mono createOrReplaceRoomMember(String roomId, String user * * @param roomId Room identifier. * @param userId User ID of the member. - * @param resource The resource instance. + * @param member The resource instance. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. @@ -1443,10 +1455,10 @@ public Mono createOrReplaceRoomMember(String roomId, String user */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Mono createOrReplaceRoomMember(String roomId, String userId, ChatRoomMember resource) { + public Mono createOrReplaceRoomMember(String roomId, String userId, ChatRoomMember member) { // Generated convenience method for createOrReplaceRoomMemberWithResponse RequestOptions requestOptions = new RequestOptions(); - return createOrReplaceRoomMemberWithResponse(roomId, userId, BinaryData.fromObject(resource), requestOptions) + return createOrReplaceRoomMemberWithResponse(roomId, userId, BinaryData.fromObject(member), requestOptions) .flatMap(FluxUtil::toMono) .map(protocolMethodData -> protocolMethodData.toObject(ChatRoomMember.class)); } @@ -1535,7 +1547,7 @@ public Mono getUser(String userId) { * `kind` discriminator. * * @param userId User identifier. - * @param resource The resource instance. + * @param user The resource instance. * @param matchConditions Specifies HTTP options for conditional requests. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. @@ -1547,7 +1559,7 @@ public Mono getUser(String userId) { */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Mono createOrReplaceUser(String userId, ChatUser resource, MatchConditions matchConditions) { + public Mono createOrReplaceUser(String userId, ChatUser user, MatchConditions matchConditions) { // Generated convenience method for createOrReplaceUserWithResponse RequestOptions requestOptions = new RequestOptions(); String ifMatch = matchConditions == null ? null : matchConditions.getIfMatch(); @@ -1558,7 +1570,7 @@ public Mono createOrReplaceUser(String userId, ChatUser resource, Matc if (ifNoneMatch != null) { requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); } - return createOrReplaceUserWithResponse(userId, BinaryData.fromObject(resource), requestOptions) + return createOrReplaceUserWithResponse(userId, BinaryData.fromObject(user), requestOptions) .flatMap(FluxUtil::toMono) .map(protocolMethodData -> protocolMethodData.toObject(ChatUser.class)); } @@ -1570,7 +1582,7 @@ public Mono createOrReplaceUser(String userId, ChatUser resource, Matc * `kind` discriminator. * * @param userId User identifier. - * @param resource The resource instance. + * @param user The resource instance. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. @@ -1581,10 +1593,10 @@ public Mono createOrReplaceUser(String userId, ChatUser resource, Matc */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Mono createOrReplaceUser(String userId, ChatUser resource) { + public Mono createOrReplaceUser(String userId, ChatUser user) { // Generated convenience method for createOrReplaceUserWithResponse RequestOptions requestOptions = new RequestOptions(); - return createOrReplaceUserWithResponse(userId, BinaryData.fromObject(resource), requestOptions) + return createOrReplaceUserWithResponse(userId, BinaryData.fromObject(user), requestOptions) .flatMap(FluxUtil::toMono) .map(protocolMethodData -> protocolMethodData.toObject(ChatUser.class)); } @@ -1643,11 +1655,15 @@ public Mono deleteUser(String userId) { /** * Creates a client access token for connecting to Azure Web PubSub Chat. + * Clients authenticated with an access key sign the token locally; clients authenticated with + * Microsoft Entra ID request the token from the service. * * @param options Options for creating the client access token. * @return A publisher containing the client access token. + * @throws NullPointerException if options or its token lifetime is null. + * @throws IllegalArgumentException if the token lifetime is outside the supported range. */ - public Mono getClientAccessToken(GetClientAccessTokenOptions options) { + public Mono getClientAccessToken(ClientAccessTokenOptions options) { return WebPubSubClientAccessTokenFactory.createAsync(serviceClient, keyCredential, options); } @@ -1780,7 +1796,7 @@ public PagedFlux listTopics(String roomId, RequestOptions requestOpt * * @param roomId Room identifier. * @param topicId Topic identifier unique within the room. - * @param resource The resource instance. + * @param topic The resource instance. * @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. @@ -1790,9 +1806,9 @@ public PagedFlux listTopics(String roomId, RequestOptions requestOpt */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> createOrReplaceTopicWithResponse(String roomId, String topicId, - BinaryData resource, RequestOptions requestOptions) { - return this.serviceClient.createOrReplaceTopicWithResponseAsync(roomId, topicId, resource, requestOptions); + public Mono> createOrReplaceTopicWithResponse(String roomId, String topicId, BinaryData topic, + RequestOptions requestOptions) { + return this.serviceClient.createOrReplaceTopicWithResponseAsync(roomId, topicId, topic, requestOptions); } /** @@ -1877,7 +1893,7 @@ public Mono> getTopicWithResponse(String roomId, String top * * @param roomId Room identifier. * @param topicId Topic identifier unique within the room. - * @param resource The resource instance. + * @param topic The resource instance. * @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. @@ -1887,9 +1903,9 @@ public Mono> getTopicWithResponse(String roomId, String top */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> updateTopicWithResponse(String roomId, String topicId, BinaryData resource, + public Mono> updateTopicWithResponse(String roomId, String topicId, BinaryData topic, RequestOptions requestOptions) { - return this.serviceClient.updateTopicWithResponseAsync(roomId, topicId, resource, requestOptions); + return this.serviceClient.updateTopicWithResponseAsync(roomId, topicId, topic, requestOptions); } /** @@ -2164,7 +2180,7 @@ public PagedFlux listTopics(String roomId) { * * @param roomId Room identifier. * @param topicId Topic identifier unique within the room. - * @param resource The resource instance. + * @param topic The resource instance. * @param matchConditions Specifies HTTP options for conditional requests. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. @@ -2176,7 +2192,7 @@ public PagedFlux listTopics(String roomId) { */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Mono createOrReplaceTopic(String roomId, String topicId, ChatTopic resource, + public Mono createOrReplaceTopic(String roomId, String topicId, ChatTopic topic, MatchConditions matchConditions) { // Generated convenience method for createOrReplaceTopicWithResponse RequestOptions requestOptions = new RequestOptions(); @@ -2188,7 +2204,7 @@ public Mono createOrReplaceTopic(String roomId, String topicId, ChatT if (ifNoneMatch != null) { requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); } - return createOrReplaceTopicWithResponse(roomId, topicId, BinaryData.fromObject(resource), requestOptions) + return createOrReplaceTopicWithResponse(roomId, topicId, BinaryData.fromObject(topic), requestOptions) .flatMap(FluxUtil::toMono) .map(protocolMethodData -> protocolMethodData.toObject(ChatTopic.class)); } @@ -2203,7 +2219,7 @@ public Mono createOrReplaceTopic(String roomId, String topicId, ChatT * * @param roomId Room identifier. * @param topicId Topic identifier unique within the room. - * @param resource The resource instance. + * @param topic The resource instance. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. @@ -2214,10 +2230,10 @@ public Mono createOrReplaceTopic(String roomId, String topicId, ChatT */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Mono createOrReplaceTopic(String roomId, String topicId, ChatTopic resource) { + public Mono createOrReplaceTopic(String roomId, String topicId, ChatTopic topic) { // Generated convenience method for createOrReplaceTopicWithResponse RequestOptions requestOptions = new RequestOptions(); - return createOrReplaceTopicWithResponse(roomId, topicId, BinaryData.fromObject(resource), requestOptions) + return createOrReplaceTopicWithResponse(roomId, topicId, BinaryData.fromObject(topic), requestOptions) .flatMap(FluxUtil::toMono) .map(protocolMethodData -> protocolMethodData.toObject(ChatTopic.class)); } @@ -2249,7 +2265,7 @@ public Mono getTopic(String roomId, String topicId) { * * @param roomId Room identifier. * @param topicId Topic identifier unique within the room. - * @param resource The resource instance. + * @param topic The resource instance. * @param matchConditions Specifies HTTP options for conditional requests. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. @@ -2261,7 +2277,7 @@ public Mono getTopic(String roomId, String topicId) { */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Mono updateTopic(String roomId, String topicId, ChatTopic resource, + public Mono updateTopic(String roomId, String topicId, ChatTopic topic, MatchConditions matchConditions) { // Generated convenience method for updateTopicWithResponse RequestOptions requestOptions = new RequestOptions(); @@ -2273,12 +2289,12 @@ public Mono updateTopic(String roomId, String topicId, ChatTopic reso if (ifNoneMatch != null) { requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); } - JsonMergePatchHelper.getChatTopicAccessor().prepareModelForJsonMergePatch(resource, true); - BinaryData resourceInBinaryData = BinaryData.fromObject(resource); + JsonMergePatchHelper.getChatTopicAccessor().prepareModelForJsonMergePatch(topic, true); + BinaryData topicInBinaryData = BinaryData.fromObject(topic); // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. - resourceInBinaryData.getLength(); - JsonMergePatchHelper.getChatTopicAccessor().prepareModelForJsonMergePatch(resource, false); - return updateTopicWithResponse(roomId, topicId, resourceInBinaryData, requestOptions).flatMap(FluxUtil::toMono) + topicInBinaryData.getLength(); + JsonMergePatchHelper.getChatTopicAccessor().prepareModelForJsonMergePatch(topic, false); + return updateTopicWithResponse(roomId, topicId, topicInBinaryData, requestOptions).flatMap(FluxUtil::toMono) .map(protocolMethodData -> protocolMethodData.toObject(ChatTopic.class)); } @@ -2287,7 +2303,7 @@ public Mono updateTopic(String roomId, String topicId, ChatTopic reso * * @param roomId Room identifier. * @param topicId Topic identifier unique within the room. - * @param resource The resource instance. + * @param topic The resource instance. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. @@ -2298,15 +2314,15 @@ public Mono updateTopic(String roomId, String topicId, ChatTopic reso */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Mono updateTopic(String roomId, String topicId, ChatTopic resource) { + public Mono updateTopic(String roomId, String topicId, ChatTopic topic) { // Generated convenience method for updateTopicWithResponse RequestOptions requestOptions = new RequestOptions(); - JsonMergePatchHelper.getChatTopicAccessor().prepareModelForJsonMergePatch(resource, true); - BinaryData resourceInBinaryData = BinaryData.fromObject(resource); + JsonMergePatchHelper.getChatTopicAccessor().prepareModelForJsonMergePatch(topic, true); + BinaryData topicInBinaryData = BinaryData.fromObject(topic); // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. - resourceInBinaryData.getLength(); - JsonMergePatchHelper.getChatTopicAccessor().prepareModelForJsonMergePatch(resource, false); - return updateTopicWithResponse(roomId, topicId, resourceInBinaryData, requestOptions).flatMap(FluxUtil::toMono) + topicInBinaryData.getLength(); + JsonMergePatchHelper.getChatTopicAccessor().prepareModelForJsonMergePatch(topic, false); + return updateTopicWithResponse(roomId, topicId, topicInBinaryData, requestOptions).flatMap(FluxUtil::toMono) .map(protocolMethodData -> protocolMethodData.toObject(ChatTopic.class)); } diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceClient.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceClient.java index d3ed05f41b000..1f93cb6fda8c2 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceClient.java +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceClient.java @@ -28,7 +28,7 @@ import com.azure.messaging.webpubsub.chat.models.ChatTopic; import com.azure.messaging.webpubsub.chat.models.ChatUser; import com.azure.messaging.webpubsub.chat.models.ChatUserRoom; -import com.azure.messaging.webpubsub.chat.models.GetClientAccessTokenOptions; +import com.azure.messaging.webpubsub.chat.models.ClientAccessTokenOptions; import com.azure.messaging.webpubsub.chat.models.WebPubSubClientAccessToken; /** @@ -80,6 +80,10 @@ public Response getConversationWithResponse(String conversationId, R /** * Query messages in a conversation from latest to earliest. + * + * Query messages in a conversation from latest to earliest. + * Message IDs are used as pagination cursors. Follow the response nextLink, + * which contains the message ID cursor, to retrieve the next page. *

Query Parameters

* * @@ -202,7 +206,7 @@ public Response deleteMessageWithResponse(String conversationId, String me * * @param conversationId Conversation identifier. * @param messageId Message identifier. - * @param resource The resource instance. + * @param message The resource instance. * @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. @@ -212,9 +216,9 @@ public Response deleteMessageWithResponse(String conversationId, String me */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Response updateMessageWithResponse(String conversationId, String messageId, BinaryData resource, + public Response updateMessageWithResponse(String conversationId, String messageId, BinaryData message, RequestOptions requestOptions) { - return this.serviceClient.updateMessageWithResponse(conversationId, messageId, resource, requestOptions); + return this.serviceClient.updateMessageWithResponse(conversationId, messageId, message, requestOptions); } /** @@ -330,7 +334,7 @@ public Response getRoleWithResponse(String roleName, RequestOptions *
Query Parameters
* * @param roleName Role name. Must start with 'user.' or 'room.' prefix. - * @param resource The resource instance. + * @param role The resource instance. * @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. @@ -342,9 +346,9 @@ public Response getRoleWithResponse(String roleName, RequestOptions */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Response createOrReplaceRoleWithResponse(String roleName, BinaryData resource, + public Response createOrReplaceRoleWithResponse(String roleName, BinaryData role, RequestOptions requestOptions) { - return this.serviceClient.createOrReplaceRoleWithResponse(roleName, resource, requestOptions); + return this.serviceClient.createOrReplaceRoleWithResponse(roleName, role, requestOptions); } /** @@ -419,7 +423,7 @@ public Response deleteRoleWithResponse(String roleName, RequestOptions req * * * @param roomId Room identifier. - * @param resource The resource instance. + * @param room The resource instance. * @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. @@ -429,9 +433,9 @@ public Response deleteRoleWithResponse(String roleName, RequestOptions req */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Response createOrReplaceRoomWithResponse(String roomId, BinaryData resource, + public Response createOrReplaceRoomWithResponse(String roomId, BinaryData room, RequestOptions requestOptions) { - return this.serviceClient.createOrReplaceRoomWithResponse(roomId, resource, requestOptions); + return this.serviceClient.createOrReplaceRoomWithResponse(roomId, room, requestOptions); } /** @@ -569,7 +573,7 @@ public PagedIterable listRoomMembers(String roomId, RequestOptions r * * @param roomId Room identifier. * @param userId User ID of the member. - * @param resource The resource instance. + * @param member The resource instance. * @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. @@ -579,9 +583,9 @@ public PagedIterable listRoomMembers(String roomId, RequestOptions r */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Response createOrReplaceRoomMemberWithResponse(String roomId, String userId, BinaryData resource, + public Response createOrReplaceRoomMemberWithResponse(String roomId, String userId, BinaryData member, RequestOptions requestOptions) { - return this.serviceClient.createOrReplaceRoomMemberWithResponse(roomId, userId, resource, requestOptions); + return this.serviceClient.createOrReplaceRoomMemberWithResponse(roomId, userId, member, requestOptions); } /** @@ -693,7 +697,7 @@ public Response getUserWithResponse(String userId, RequestOptions re * * * @param userId User identifier. - * @param resource The resource instance. + * @param user The resource instance. * @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. @@ -703,9 +707,9 @@ public Response getUserWithResponse(String userId, RequestOptions re */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Response createOrReplaceUserWithResponse(String userId, BinaryData resource, + public Response createOrReplaceUserWithResponse(String userId, BinaryData user, RequestOptions requestOptions) { - return this.serviceClient.createOrReplaceUserWithResponse(userId, resource, requestOptions); + return this.serviceClient.createOrReplaceUserWithResponse(userId, user, requestOptions); } /** @@ -758,6 +762,10 @@ public ChatConversation getConversation(String conversationId) { /** * Query messages in a conversation from latest to earliest. * + * Query messages in a conversation from latest to earliest. + * Message IDs are used as pagination cursors. Follow the response nextLink, + * which contains the message ID cursor, to retrieve the next page. + * * @param conversationId Conversation identifier. * @param latestMessageId Latest message ID (exclusive) for pagination. * @param earliestMessageId Earliest message ID (exclusive) for pagination. @@ -788,6 +796,10 @@ public PagedIterable listMessages(String conversationId, String lat /** * Query messages in a conversation from latest to earliest. * + * Query messages in a conversation from latest to earliest. + * Message IDs are used as pagination cursors. Follow the response nextLink, + * which contains the message ID cursor, to retrieve the next page. + * * @param conversationId Conversation identifier. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. @@ -860,7 +872,7 @@ public void deleteMessage(String conversationId, String messageId) { * * @param conversationId Conversation identifier. * @param messageId Message identifier. - * @param resource The resource instance. + * @param message The resource instance. * @param matchConditions Specifies HTTP options for conditional requests. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. @@ -872,7 +884,7 @@ public void deleteMessage(String conversationId, String messageId) { */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public ChatMessage updateMessage(String conversationId, String messageId, ChatMessage resource, + public ChatMessage updateMessage(String conversationId, String messageId, ChatMessage message, MatchConditions matchConditions) { // Generated convenience method for updateMessageWithResponse RequestOptions requestOptions = new RequestOptions(); @@ -884,12 +896,12 @@ public ChatMessage updateMessage(String conversationId, String messageId, ChatMe if (ifNoneMatch != null) { requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); } - JsonMergePatchHelper.getChatMessageAccessor().prepareModelForJsonMergePatch(resource, true); - BinaryData resourceInBinaryData = BinaryData.fromObject(resource); + JsonMergePatchHelper.getChatMessageAccessor().prepareModelForJsonMergePatch(message, true); + BinaryData messageInBinaryData = BinaryData.fromObject(message); // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. - resourceInBinaryData.getLength(); - JsonMergePatchHelper.getChatMessageAccessor().prepareModelForJsonMergePatch(resource, false); - return updateMessageWithResponse(conversationId, messageId, resourceInBinaryData, requestOptions).getValue() + messageInBinaryData.getLength(); + JsonMergePatchHelper.getChatMessageAccessor().prepareModelForJsonMergePatch(message, false); + return updateMessageWithResponse(conversationId, messageId, messageInBinaryData, requestOptions).getValue() .toObject(ChatMessage.class); } @@ -898,7 +910,7 @@ public ChatMessage updateMessage(String conversationId, String messageId, ChatMe * * @param conversationId Conversation identifier. * @param messageId Message identifier. - * @param resource The resource instance. + * @param message The resource instance. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. @@ -909,15 +921,15 @@ public ChatMessage updateMessage(String conversationId, String messageId, ChatMe */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public ChatMessage updateMessage(String conversationId, String messageId, ChatMessage resource) { + public ChatMessage updateMessage(String conversationId, String messageId, ChatMessage message) { // Generated convenience method for updateMessageWithResponse RequestOptions requestOptions = new RequestOptions(); - JsonMergePatchHelper.getChatMessageAccessor().prepareModelForJsonMergePatch(resource, true); - BinaryData resourceInBinaryData = BinaryData.fromObject(resource); + JsonMergePatchHelper.getChatMessageAccessor().prepareModelForJsonMergePatch(message, true); + BinaryData messageInBinaryData = BinaryData.fromObject(message); // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. - resourceInBinaryData.getLength(); - JsonMergePatchHelper.getChatMessageAccessor().prepareModelForJsonMergePatch(resource, false); - return updateMessageWithResponse(conversationId, messageId, resourceInBinaryData, requestOptions).getValue() + messageInBinaryData.getLength(); + JsonMergePatchHelper.getChatMessageAccessor().prepareModelForJsonMergePatch(message, false); + return updateMessageWithResponse(conversationId, messageId, messageInBinaryData, requestOptions).getValue() .toObject(ChatMessage.class); } @@ -986,7 +998,7 @@ public ChatRole getRole(String roleName) { * Create or replace a role. * * @param roleName Role name. Must start with 'user.' or 'room.' prefix. - * @param resource The resource instance. + * @param role The resource instance. * @param matchConditions Specifies HTTP options for conditional requests. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. @@ -1000,7 +1012,7 @@ public ChatRole getRole(String roleName) { */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public ChatRole createOrReplaceRole(String roleName, ChatRole resource, MatchConditions matchConditions) { + public ChatRole createOrReplaceRole(String roleName, ChatRole role, MatchConditions matchConditions) { // Generated convenience method for createOrReplaceRoleWithResponse RequestOptions requestOptions = new RequestOptions(); String ifMatch = matchConditions == null ? null : matchConditions.getIfMatch(); @@ -1011,7 +1023,7 @@ public ChatRole createOrReplaceRole(String roleName, ChatRole resource, MatchCon if (ifNoneMatch != null) { requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); } - return createOrReplaceRoleWithResponse(roleName, BinaryData.fromObject(resource), requestOptions).getValue() + return createOrReplaceRoleWithResponse(roleName, BinaryData.fromObject(role), requestOptions).getValue() .toObject(ChatRole.class); } @@ -1019,7 +1031,7 @@ public ChatRole createOrReplaceRole(String roleName, ChatRole resource, MatchCon * Create or replace a role. * * @param roleName Role name. Must start with 'user.' or 'room.' prefix. - * @param resource The resource instance. + * @param role The resource instance. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. @@ -1032,10 +1044,10 @@ public ChatRole createOrReplaceRole(String roleName, ChatRole resource, MatchCon */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public ChatRole createOrReplaceRole(String roleName, ChatRole resource) { + public ChatRole createOrReplaceRole(String roleName, ChatRole role) { // Generated convenience method for createOrReplaceRoleWithResponse RequestOptions requestOptions = new RequestOptions(); - return createOrReplaceRoleWithResponse(roleName, BinaryData.fromObject(resource), requestOptions).getValue() + return createOrReplaceRoleWithResponse(roleName, BinaryData.fromObject(role), requestOptions).getValue() .toObject(ChatRole.class); } @@ -1092,7 +1104,7 @@ public void deleteRole(String roleName) { * Create or replace a room with a client-specified ID. * * @param roomId Room identifier. - * @param resource The resource instance. + * @param room The resource instance. * @param matchConditions Specifies HTTP options for conditional requests. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. @@ -1104,7 +1116,7 @@ public void deleteRole(String roleName) { */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public ChatRoom createOrReplaceRoom(String roomId, ChatRoom resource, MatchConditions matchConditions) { + public ChatRoom createOrReplaceRoom(String roomId, ChatRoom room, MatchConditions matchConditions) { // Generated convenience method for createOrReplaceRoomWithResponse RequestOptions requestOptions = new RequestOptions(); String ifMatch = matchConditions == null ? null : matchConditions.getIfMatch(); @@ -1115,7 +1127,7 @@ public ChatRoom createOrReplaceRoom(String roomId, ChatRoom resource, MatchCondi if (ifNoneMatch != null) { requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); } - return createOrReplaceRoomWithResponse(roomId, BinaryData.fromObject(resource), requestOptions).getValue() + return createOrReplaceRoomWithResponse(roomId, BinaryData.fromObject(room), requestOptions).getValue() .toObject(ChatRoom.class); } @@ -1125,7 +1137,7 @@ public ChatRoom createOrReplaceRoom(String roomId, ChatRoom resource, MatchCondi * Create or replace a room with a client-specified ID. * * @param roomId Room identifier. - * @param resource The resource instance. + * @param room The resource instance. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. @@ -1136,10 +1148,10 @@ public ChatRoom createOrReplaceRoom(String roomId, ChatRoom resource, MatchCondi */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public ChatRoom createOrReplaceRoom(String roomId, ChatRoom resource) { + public ChatRoom createOrReplaceRoom(String roomId, ChatRoom room) { // Generated convenience method for createOrReplaceRoomWithResponse RequestOptions requestOptions = new RequestOptions(); - return createOrReplaceRoomWithResponse(roomId, BinaryData.fromObject(resource), requestOptions).getValue() + return createOrReplaceRoomWithResponse(roomId, BinaryData.fromObject(room), requestOptions).getValue() .toObject(ChatRoom.class); } @@ -1261,7 +1273,7 @@ public PagedIterable listRoomMembers(String roomId) { * * @param roomId Room identifier. * @param userId User ID of the member. - * @param resource The resource instance. + * @param member The resource instance. * @param matchConditions Specifies HTTP options for conditional requests. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. @@ -1273,7 +1285,7 @@ public PagedIterable listRoomMembers(String roomId) { */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public ChatRoomMember createOrReplaceRoomMember(String roomId, String userId, ChatRoomMember resource, + public ChatRoomMember createOrReplaceRoomMember(String roomId, String userId, ChatRoomMember member, MatchConditions matchConditions) { // Generated convenience method for createOrReplaceRoomMemberWithResponse RequestOptions requestOptions = new RequestOptions(); @@ -1285,7 +1297,7 @@ public ChatRoomMember createOrReplaceRoomMember(String roomId, String userId, Ch if (ifNoneMatch != null) { requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); } - return createOrReplaceRoomMemberWithResponse(roomId, userId, BinaryData.fromObject(resource), requestOptions) + return createOrReplaceRoomMemberWithResponse(roomId, userId, BinaryData.fromObject(member), requestOptions) .getValue() .toObject(ChatRoomMember.class); } @@ -1295,7 +1307,7 @@ public ChatRoomMember createOrReplaceRoomMember(String roomId, String userId, Ch * * @param roomId Room identifier. * @param userId User ID of the member. - * @param resource The resource instance. + * @param member The resource instance. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. @@ -1306,10 +1318,10 @@ public ChatRoomMember createOrReplaceRoomMember(String roomId, String userId, Ch */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public ChatRoomMember createOrReplaceRoomMember(String roomId, String userId, ChatRoomMember resource) { + public ChatRoomMember createOrReplaceRoomMember(String roomId, String userId, ChatRoomMember member) { // Generated convenience method for createOrReplaceRoomMemberWithResponse RequestOptions requestOptions = new RequestOptions(); - return createOrReplaceRoomMemberWithResponse(roomId, userId, BinaryData.fromObject(resource), requestOptions) + return createOrReplaceRoomMemberWithResponse(roomId, userId, BinaryData.fromObject(member), requestOptions) .getValue() .toObject(ChatRoomMember.class); } @@ -1395,7 +1407,7 @@ public ChatUser getUser(String userId) { * `kind` discriminator. * * @param userId User identifier. - * @param resource The resource instance. + * @param user The resource instance. * @param matchConditions Specifies HTTP options for conditional requests. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. @@ -1407,7 +1419,7 @@ public ChatUser getUser(String userId) { */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public ChatUser createOrReplaceUser(String userId, ChatUser resource, MatchConditions matchConditions) { + public ChatUser createOrReplaceUser(String userId, ChatUser user, MatchConditions matchConditions) { // Generated convenience method for createOrReplaceUserWithResponse RequestOptions requestOptions = new RequestOptions(); String ifMatch = matchConditions == null ? null : matchConditions.getIfMatch(); @@ -1418,7 +1430,7 @@ public ChatUser createOrReplaceUser(String userId, ChatUser resource, MatchCondi if (ifNoneMatch != null) { requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); } - return createOrReplaceUserWithResponse(userId, BinaryData.fromObject(resource), requestOptions).getValue() + return createOrReplaceUserWithResponse(userId, BinaryData.fromObject(user), requestOptions).getValue() .toObject(ChatUser.class); } @@ -1429,7 +1441,7 @@ public ChatUser createOrReplaceUser(String userId, ChatUser resource, MatchCondi * `kind` discriminator. * * @param userId User identifier. - * @param resource The resource instance. + * @param user The resource instance. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. @@ -1440,10 +1452,10 @@ public ChatUser createOrReplaceUser(String userId, ChatUser resource, MatchCondi */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public ChatUser createOrReplaceUser(String userId, ChatUser resource) { + public ChatUser createOrReplaceUser(String userId, ChatUser user) { // Generated convenience method for createOrReplaceUserWithResponse RequestOptions requestOptions = new RequestOptions(); - return createOrReplaceUserWithResponse(userId, BinaryData.fromObject(resource), requestOptions).getValue() + return createOrReplaceUserWithResponse(userId, BinaryData.fromObject(user), requestOptions).getValue() .toObject(ChatUser.class); } @@ -1499,11 +1511,15 @@ public void deleteUser(String userId) { /** * Creates a client access token for connecting to Azure Web PubSub Chat. + * Clients authenticated with an access key sign the token locally; clients authenticated with + * Microsoft Entra ID request the token from the service. * * @param options Options for creating the client access token. * @return The client access token. + * @throws NullPointerException if options or its token lifetime is null. + * @throws IllegalArgumentException if the token lifetime is outside the supported range. */ - public WebPubSubClientAccessToken getClientAccessToken(GetClientAccessTokenOptions options) { + public WebPubSubClientAccessToken getClientAccessToken(ClientAccessTokenOptions options) { return WebPubSubClientAccessTokenFactory.create(serviceClient, keyCredential, options); } @@ -1636,7 +1652,7 @@ public PagedIterable listTopics(String roomId, RequestOptions reques * * @param roomId Room identifier. * @param topicId Topic identifier unique within the room. - * @param resource The resource instance. + * @param topic The resource instance. * @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. @@ -1646,9 +1662,9 @@ public PagedIterable listTopics(String roomId, RequestOptions reques */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Response createOrReplaceTopicWithResponse(String roomId, String topicId, BinaryData resource, + public Response createOrReplaceTopicWithResponse(String roomId, String topicId, BinaryData topic, RequestOptions requestOptions) { - return this.serviceClient.createOrReplaceTopicWithResponse(roomId, topicId, resource, requestOptions); + return this.serviceClient.createOrReplaceTopicWithResponse(roomId, topicId, topic, requestOptions); } /** @@ -1732,7 +1748,7 @@ public Response getTopicWithResponse(String roomId, String topicId, * * @param roomId Room identifier. * @param topicId Topic identifier unique within the room. - * @param resource The resource instance. + * @param topic The resource instance. * @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. @@ -1742,9 +1758,9 @@ public Response getTopicWithResponse(String roomId, String topicId, */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Response updateTopicWithResponse(String roomId, String topicId, BinaryData resource, + public Response updateTopicWithResponse(String roomId, String topicId, BinaryData topic, RequestOptions requestOptions) { - return this.serviceClient.updateTopicWithResponse(roomId, topicId, resource, requestOptions); + return this.serviceClient.updateTopicWithResponse(roomId, topicId, topic, requestOptions); } /** @@ -1945,7 +1961,7 @@ public PagedIterable listTopics(String roomId) { * * @param roomId Room identifier. * @param topicId Topic identifier unique within the room. - * @param resource The resource instance. + * @param topic The resource instance. * @param matchConditions Specifies HTTP options for conditional requests. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. @@ -1957,7 +1973,7 @@ public PagedIterable listTopics(String roomId) { */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public ChatTopic createOrReplaceTopic(String roomId, String topicId, ChatTopic resource, + public ChatTopic createOrReplaceTopic(String roomId, String topicId, ChatTopic topic, MatchConditions matchConditions) { // Generated convenience method for createOrReplaceTopicWithResponse RequestOptions requestOptions = new RequestOptions(); @@ -1969,7 +1985,7 @@ public ChatTopic createOrReplaceTopic(String roomId, String topicId, ChatTopic r if (ifNoneMatch != null) { requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); } - return createOrReplaceTopicWithResponse(roomId, topicId, BinaryData.fromObject(resource), requestOptions) + return createOrReplaceTopicWithResponse(roomId, topicId, BinaryData.fromObject(topic), requestOptions) .getValue() .toObject(ChatTopic.class); } @@ -1984,7 +2000,7 @@ public ChatTopic createOrReplaceTopic(String roomId, String topicId, ChatTopic r * * @param roomId Room identifier. * @param topicId Topic identifier unique within the room. - * @param resource The resource instance. + * @param topic The resource instance. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. @@ -1995,10 +2011,10 @@ public ChatTopic createOrReplaceTopic(String roomId, String topicId, ChatTopic r */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public ChatTopic createOrReplaceTopic(String roomId, String topicId, ChatTopic resource) { + public ChatTopic createOrReplaceTopic(String roomId, String topicId, ChatTopic topic) { // Generated convenience method for createOrReplaceTopicWithResponse RequestOptions requestOptions = new RequestOptions(); - return createOrReplaceTopicWithResponse(roomId, topicId, BinaryData.fromObject(resource), requestOptions) + return createOrReplaceTopicWithResponse(roomId, topicId, BinaryData.fromObject(topic), requestOptions) .getValue() .toObject(ChatTopic.class); } @@ -2029,7 +2045,7 @@ public ChatTopic getTopic(String roomId, String topicId) { * * @param roomId Room identifier. * @param topicId Topic identifier unique within the room. - * @param resource The resource instance. + * @param topic The resource instance. * @param matchConditions Specifies HTTP options for conditional requests. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. @@ -2041,7 +2057,7 @@ public ChatTopic getTopic(String roomId, String topicId) { */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public ChatTopic updateTopic(String roomId, String topicId, ChatTopic resource, MatchConditions matchConditions) { + public ChatTopic updateTopic(String roomId, String topicId, ChatTopic topic, MatchConditions matchConditions) { // Generated convenience method for updateTopicWithResponse RequestOptions requestOptions = new RequestOptions(); String ifMatch = matchConditions == null ? null : matchConditions.getIfMatch(); @@ -2052,12 +2068,12 @@ public ChatTopic updateTopic(String roomId, String topicId, ChatTopic resource, if (ifNoneMatch != null) { requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); } - JsonMergePatchHelper.getChatTopicAccessor().prepareModelForJsonMergePatch(resource, true); - BinaryData resourceInBinaryData = BinaryData.fromObject(resource); + JsonMergePatchHelper.getChatTopicAccessor().prepareModelForJsonMergePatch(topic, true); + BinaryData topicInBinaryData = BinaryData.fromObject(topic); // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. - resourceInBinaryData.getLength(); - JsonMergePatchHelper.getChatTopicAccessor().prepareModelForJsonMergePatch(resource, false); - return updateTopicWithResponse(roomId, topicId, resourceInBinaryData, requestOptions).getValue() + topicInBinaryData.getLength(); + JsonMergePatchHelper.getChatTopicAccessor().prepareModelForJsonMergePatch(topic, false); + return updateTopicWithResponse(roomId, topicId, topicInBinaryData, requestOptions).getValue() .toObject(ChatTopic.class); } @@ -2066,7 +2082,7 @@ public ChatTopic updateTopic(String roomId, String topicId, ChatTopic resource, * * @param roomId Room identifier. * @param topicId Topic identifier unique within the room. - * @param resource The resource instance. + * @param topic The resource instance. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. @@ -2077,15 +2093,15 @@ public ChatTopic updateTopic(String roomId, String topicId, ChatTopic resource, */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public ChatTopic updateTopic(String roomId, String topicId, ChatTopic resource) { + public ChatTopic updateTopic(String roomId, String topicId, ChatTopic topic) { // Generated convenience method for updateTopicWithResponse RequestOptions requestOptions = new RequestOptions(); - JsonMergePatchHelper.getChatTopicAccessor().prepareModelForJsonMergePatch(resource, true); - BinaryData resourceInBinaryData = BinaryData.fromObject(resource); + JsonMergePatchHelper.getChatTopicAccessor().prepareModelForJsonMergePatch(topic, true); + BinaryData topicInBinaryData = BinaryData.fromObject(topic); // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. - resourceInBinaryData.getLength(); - JsonMergePatchHelper.getChatTopicAccessor().prepareModelForJsonMergePatch(resource, false); - return updateTopicWithResponse(roomId, topicId, resourceInBinaryData, requestOptions).getValue() + topicInBinaryData.getLength(); + JsonMergePatchHelper.getChatTopicAccessor().prepareModelForJsonMergePatch(topic, false); + return updateTopicWithResponse(roomId, topicId, topicInBinaryData, requestOptions).getValue() .toObject(ChatTopic.class); } diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubClientAccessTokenFactory.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubClientAccessTokenFactory.java index ef59a604380a6..1cf107ce91f3a 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubClientAccessTokenFactory.java +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubClientAccessTokenFactory.java @@ -7,7 +7,7 @@ import com.azure.core.http.rest.RequestOptions; import com.azure.messaging.webpubsub.chat.implementation.WebPubSubChatServiceClientImpl; import com.azure.messaging.webpubsub.chat.implementation.models.GenerateClientTokenResponse; -import com.azure.messaging.webpubsub.chat.models.GetClientAccessTokenOptions; +import com.azure.messaging.webpubsub.chat.models.ClientAccessTokenOptions; import com.azure.messaging.webpubsub.chat.models.WebPubSubClientAccessToken; import reactor.core.publisher.Mono; @@ -20,7 +20,7 @@ final class WebPubSubClientAccessTokenFactory { private static final List CHAT_ROLES = Arrays.asList("webpubsub.getGroupState", "webpubsub.setGroupState"); static WebPubSubClientAccessToken create(WebPubSubChatServiceClientImpl serviceClient, - AzureKeyCredential keyCredential, GetClientAccessTokenOptions options) { + AzureKeyCredential keyCredential, ClientAccessTokenOptions options) { Objects.requireNonNull(options, "'options' cannot be null."); Duration expiresAfter = validateExpiresAfter(options.getExpiresAfter()); String token; @@ -38,7 +38,7 @@ static WebPubSubClientAccessToken create(WebPubSubChatServiceClientImpl serviceC } static Mono createAsync(WebPubSubChatServiceClientImpl serviceClient, - AzureKeyCredential keyCredential, GetClientAccessTokenOptions options) { + AzureKeyCredential keyCredential, ClientAccessTokenOptions options) { Objects.requireNonNull(options, "'options' cannot be null."); Duration expiresAfter = validateExpiresAfter(options.getExpiresAfter()); if (keyCredential == null) { @@ -51,7 +51,7 @@ static Mono createAsync(WebPubSubChatServiceClientIm return Mono.fromCallable(() -> create(serviceClient, keyCredential, options)); } - private static RequestOptions createRequestOptions(GetClientAccessTokenOptions options, Duration expiresAfter) { + private static RequestOptions createRequestOptions(ClientAccessTokenOptions options, Duration expiresAfter) { RequestOptions requestOptions = new RequestOptions(); requestOptions.addQueryParam("clientType", "default"); if (options.getUserId() != null) { diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/implementation/WebPubSubChatServiceClientImpl.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/implementation/WebPubSubChatServiceClientImpl.java index efdd09cdcf295..bc425f8d355c1 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/implementation/WebPubSubChatServiceClientImpl.java +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/implementation/WebPubSubChatServiceClientImpl.java @@ -259,7 +259,7 @@ Mono> updateMessage(@HostParam("endpoint") String endpoint, @QueryParam("api-version") String apiVersion, @PathParam("hub") String hub, @PathParam("conversationId") String conversationId, @PathParam("messageId") String messageId, @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, - @BodyParam("application/merge-patch+json") BinaryData resource, RequestOptions requestOptions, + @BodyParam("application/merge-patch+json") BinaryData message, RequestOptions requestOptions, Context context); @Patch("/api/hubs/{hub}/chat/conversations/{conversationId}/messages/{messageId}") @@ -272,7 +272,7 @@ Response updateMessageSync(@HostParam("endpoint") String endpoint, @QueryParam("api-version") String apiVersion, @PathParam("hub") String hub, @PathParam("conversationId") String conversationId, @PathParam("messageId") String messageId, @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, - @BodyParam("application/merge-patch+json") BinaryData resource, RequestOptions requestOptions, + @BodyParam("application/merge-patch+json") BinaryData message, RequestOptions requestOptions, Context context); @Get("/api/hubs/{hub}/chat/roles") @@ -326,7 +326,7 @@ Response getRoleSync(@HostParam("endpoint") String endpoint, Mono> createOrReplaceRole(@HostParam("endpoint") String endpoint, @QueryParam("api-version") String apiVersion, @PathParam("hub") String hub, @PathParam("roleName") String roleName, @HeaderParam("Content-Type") String contentType, - @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData resource, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData role, RequestOptions requestOptions, Context context); @Put("/api/hubs/{hub}/chat/roles/{roleName}") @@ -338,7 +338,7 @@ Mono> createOrReplaceRole(@HostParam("endpoint") String end Response createOrReplaceRoleSync(@HostParam("endpoint") String endpoint, @QueryParam("api-version") String apiVersion, @PathParam("hub") String hub, @PathParam("roleName") String roleName, @HeaderParam("Content-Type") String contentType, - @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData resource, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData role, RequestOptions requestOptions, Context context); @Delete("/api/hubs/{hub}/chat/roles/{roleName}") @@ -390,7 +390,7 @@ Response listRoomsSync(@HostParam("endpoint") String endpoint, Mono> createOrReplaceRoom(@HostParam("endpoint") String endpoint, @QueryParam("api-version") String apiVersion, @PathParam("hub") String hub, @PathParam("roomId") String roomId, @HeaderParam("Content-Type") String contentType, - @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData resource, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData room, RequestOptions requestOptions, Context context); @Put("/api/hubs/{hub}/chat/rooms/{roomId}") @@ -402,7 +402,7 @@ Mono> createOrReplaceRoom(@HostParam("endpoint") String end Response createOrReplaceRoomSync(@HostParam("endpoint") String endpoint, @QueryParam("api-version") String apiVersion, @PathParam("hub") String hub, @PathParam("roomId") String roomId, @HeaderParam("Content-Type") String contentType, - @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData resource, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData room, RequestOptions requestOptions, Context context); @Get("/api/hubs/{hub}/chat/rooms/{roomId}") @@ -479,7 +479,7 @@ Mono> createOrReplaceTopic(@HostParam("endpoint") String en @QueryParam("api-version") String apiVersion, @PathParam("hub") String hub, @PathParam("roomId") String roomId, @PathParam("topicId") String topicId, @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, - @BodyParam("application/json") BinaryData resource, RequestOptions requestOptions, Context context); + @BodyParam("application/json") BinaryData topic, RequestOptions requestOptions, Context context); @Put("/api/hubs/{hub}/chat/rooms/{roomId}/topics/{topicId}") @ExpectedResponses({ 200, 201 }) @@ -491,7 +491,7 @@ Response createOrReplaceTopicSync(@HostParam("endpoint") String endp @QueryParam("api-version") String apiVersion, @PathParam("hub") String hub, @PathParam("roomId") String roomId, @PathParam("topicId") String topicId, @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, - @BodyParam("application/json") BinaryData resource, RequestOptions requestOptions, Context context); + @BodyParam("application/json") BinaryData topic, RequestOptions requestOptions, Context context); @Get("/api/hubs/{hub}/chat/rooms/{roomId}/topics/{topicId}") @ExpectedResponses({ 200 }) @@ -525,7 +525,7 @@ Mono> updateTopic(@HostParam("endpoint") String endpoint, @QueryParam("api-version") String apiVersion, @PathParam("hub") String hub, @PathParam("roomId") String roomId, @PathParam("topicId") String topicId, @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, - @BodyParam("application/merge-patch+json") BinaryData resource, RequestOptions requestOptions, + @BodyParam("application/merge-patch+json") BinaryData topic, RequestOptions requestOptions, Context context); @Patch("/api/hubs/{hub}/chat/rooms/{roomId}/topics/{topicId}") @@ -538,7 +538,7 @@ Response updateTopicSync(@HostParam("endpoint") String endpoint, @QueryParam("api-version") String apiVersion, @PathParam("hub") String hub, @PathParam("roomId") String roomId, @PathParam("topicId") String topicId, @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, - @BodyParam("application/merge-patch+json") BinaryData resource, RequestOptions requestOptions, + @BodyParam("application/merge-patch+json") BinaryData topic, RequestOptions requestOptions, Context context); @Delete("/api/hubs/{hub}/chat/rooms/{roomId}/topics/{topicId}") @@ -595,7 +595,7 @@ Mono> createOrReplaceRoomMember(@HostParam("endpoint") Stri @QueryParam("api-version") String apiVersion, @PathParam("hub") String hub, @PathParam("roomId") String roomId, @PathParam("userId") String userId, @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, - @BodyParam("application/json") BinaryData resource, RequestOptions requestOptions, Context context); + @BodyParam("application/json") BinaryData member, RequestOptions requestOptions, Context context); @Put("/api/hubs/{hub}/chat/rooms/{roomId}/members/{userId}") @ExpectedResponses({ 200, 201 }) @@ -607,7 +607,7 @@ Response createOrReplaceRoomMemberSync(@HostParam("endpoint") String @QueryParam("api-version") String apiVersion, @PathParam("hub") String hub, @PathParam("roomId") String roomId, @PathParam("userId") String userId, @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, - @BodyParam("application/json") BinaryData resource, RequestOptions requestOptions, Context context); + @BodyParam("application/json") BinaryData member, RequestOptions requestOptions, Context context); @Delete("/api/hubs/{hub}/chat/rooms/{roomId}/members/{userId}") @ExpectedResponses({ 204 }) @@ -682,7 +682,7 @@ Response getUserSync(@HostParam("endpoint") String endpoint, Mono> createOrReplaceUser(@HostParam("endpoint") String endpoint, @QueryParam("api-version") String apiVersion, @PathParam("hub") String hub, @PathParam("userId") String userId, @HeaderParam("Content-Type") String contentType, - @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData resource, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData user, RequestOptions requestOptions, Context context); @Put("/api/hubs/{hub}/chat/users/{userId}") @@ -694,7 +694,7 @@ Mono> createOrReplaceUser(@HostParam("endpoint") String end Response createOrReplaceUserSync(@HostParam("endpoint") String endpoint, @QueryParam("api-version") String apiVersion, @PathParam("hub") String hub, @PathParam("userId") String userId, @HeaderParam("Content-Type") String contentType, - @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData resource, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData user, RequestOptions requestOptions, Context context); @Delete("/api/hubs/{hub}/chat/users/{userId}") @@ -961,6 +961,10 @@ public Response getConversationWithResponse(String conversationId, R /** * Query messages in a conversation from latest to earliest. + * + * Query messages in a conversation from latest to earliest. + * Message IDs are used as pagination cursors. Follow the response nextLink, + * which contains the message ID cursor, to retrieve the next page. *

Query Parameters

* * @@ -1010,6 +1014,10 @@ private Mono> listMessagesSinglePageAsync(String conve /** * Query messages in a conversation from latest to earliest. + * + * Query messages in a conversation from latest to earliest. + * Message IDs are used as pagination cursors. Follow the response nextLink, + * which contains the message ID cursor, to retrieve the next page. *

Query Parameters

*
Query Parameters
* @@ -1076,6 +1084,10 @@ public PagedFlux listMessagesAsync(String conversationId, RequestOpt /** * Query messages in a conversation from latest to earliest. + * + * Query messages in a conversation from latest to earliest. + * Message IDs are used as pagination cursors. Follow the response nextLink, + * which contains the message ID cursor, to retrieve the next page. *

Query Parameters

*
Query Parameters
* @@ -1122,6 +1134,10 @@ private PagedResponse listMessagesSinglePage(String conversationId, /** * Query messages in a conversation from latest to earliest. + * + * Query messages in a conversation from latest to earliest. + * Message IDs are used as pagination cursors. Follow the response nextLink, + * which contains the message ID cursor, to retrieve the next page. *

Query Parameters

*
Query Parameters
* @@ -1296,7 +1312,7 @@ public Response deleteMessageWithResponse(String conversationId, String me * * @param conversationId Conversation identifier. * @param messageId Message identifier. - * @param resource The resource instance. + * @param message The resource instance. * @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. @@ -1306,12 +1322,12 @@ public Response deleteMessageWithResponse(String conversationId, String me */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> updateMessageWithResponseAsync(String conversationId, String messageId, - BinaryData resource, RequestOptions requestOptions) { + BinaryData message, RequestOptions requestOptions) { final String contentType = "application/merge-patch+json"; final String accept = "application/json"; return FluxUtil .withContext(context -> service.updateMessage(this.getEndpoint(), this.getServiceVersion().getVersion(), - this.getHub(), conversationId, messageId, contentType, accept, resource, requestOptions, context)); + this.getHub(), conversationId, messageId, contentType, accept, message, requestOptions, context)); } /** @@ -1366,7 +1382,7 @@ public Mono> updateMessageWithResponseAsync(String conversa * * @param conversationId Conversation identifier. * @param messageId Message identifier. - * @param resource The resource instance. + * @param message The resource instance. * @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. @@ -1375,12 +1391,12 @@ public Mono> updateMessageWithResponseAsync(String conversa * @return represents a chat message along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response updateMessageWithResponse(String conversationId, String messageId, BinaryData resource, + public Response updateMessageWithResponse(String conversationId, String messageId, BinaryData message, RequestOptions requestOptions) { final String contentType = "application/merge-patch+json"; final String accept = "application/json"; return service.updateMessageSync(this.getEndpoint(), this.getServiceVersion().getVersion(), this.getHub(), - conversationId, messageId, contentType, accept, resource, requestOptions, Context.NONE); + conversationId, messageId, contentType, accept, message, requestOptions, Context.NONE); } /** @@ -1693,7 +1709,7 @@ public Response getRoleWithResponse(String roleName, RequestOptions *
Query Parameters
* * @param roleName Role name. Must start with 'user.' or 'room.' prefix. - * @param resource The resource instance. + * @param role The resource instance. * @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. @@ -1705,13 +1721,13 @@ public Response getRoleWithResponse(String roleName, RequestOptions * successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> createOrReplaceRoleWithResponseAsync(String roleName, BinaryData resource, + public Mono> createOrReplaceRoleWithResponseAsync(String roleName, BinaryData role, RequestOptions requestOptions) { final String contentType = "application/json"; final String accept = "application/json"; return FluxUtil.withContext( context -> service.createOrReplaceRole(this.getEndpoint(), this.getServiceVersion().getVersion(), - this.getHub(), roleName, contentType, accept, resource, requestOptions, context)); + this.getHub(), roleName, contentType, accept, role, requestOptions, context)); } /** @@ -1760,7 +1776,7 @@ public Mono> createOrReplaceRoleWithResponseAsync(String ro * * * @param roleName Role name. Must start with 'user.' or 'room.' prefix. - * @param resource The resource instance. + * @param role The resource instance. * @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. @@ -1771,12 +1787,12 @@ public Mono> createOrReplaceRoleWithResponseAsync(String ro * A role must contain either user permissions or room permissions, but not both along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response createOrReplaceRoleWithResponse(String roleName, BinaryData resource, + public Response createOrReplaceRoleWithResponse(String roleName, BinaryData role, RequestOptions requestOptions) { final String contentType = "application/json"; final String accept = "application/json"; return service.createOrReplaceRoleSync(this.getEndpoint(), this.getServiceVersion().getVersion(), this.getHub(), - roleName, contentType, accept, resource, requestOptions, Context.NONE); + roleName, contentType, accept, role, requestOptions, Context.NONE); } /** @@ -2076,7 +2092,7 @@ public PagedIterable listRooms(RequestOptions requestOptions) { * * * @param roomId Room identifier. - * @param resource The resource instance. + * @param room The resource instance. * @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. @@ -2085,13 +2101,13 @@ public PagedIterable listRooms(RequestOptions requestOptions) { * @return represents a chat room along with {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> createOrReplaceRoomWithResponseAsync(String roomId, BinaryData resource, + public Mono> createOrReplaceRoomWithResponseAsync(String roomId, BinaryData room, RequestOptions requestOptions) { final String contentType = "application/json"; final String accept = "application/json"; return FluxUtil.withContext( context -> service.createOrReplaceRoom(this.getEndpoint(), this.getServiceVersion().getVersion(), - this.getHub(), roomId, contentType, accept, resource, requestOptions, context)); + this.getHub(), roomId, contentType, accept, room, requestOptions, context)); } /** @@ -2139,7 +2155,7 @@ public Mono> createOrReplaceRoomWithResponseAsync(String ro * * * @param roomId Room identifier. - * @param resource The resource instance. + * @param room The resource instance. * @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. @@ -2148,12 +2164,12 @@ public Mono> createOrReplaceRoomWithResponseAsync(String ro * @return represents a chat room along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response createOrReplaceRoomWithResponse(String roomId, BinaryData resource, + public Response createOrReplaceRoomWithResponse(String roomId, BinaryData room, RequestOptions requestOptions) { final String contentType = "application/json"; final String accept = "application/json"; return service.createOrReplaceRoomSync(this.getEndpoint(), this.getServiceVersion().getVersion(), this.getHub(), - roomId, contentType, accept, resource, requestOptions, Context.NONE); + roomId, contentType, accept, room, requestOptions, Context.NONE); } /** @@ -2537,7 +2553,7 @@ public PagedIterable listTopics(String roomId, RequestOptions reques * * @param roomId Room identifier. * @param topicId Topic identifier unique within the room. - * @param resource The resource instance. + * @param topic The resource instance. * @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. @@ -2547,12 +2563,12 @@ public PagedIterable listTopics(String roomId, RequestOptions reques */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> createOrReplaceTopicWithResponseAsync(String roomId, String topicId, - BinaryData resource, RequestOptions requestOptions) { + BinaryData topic, RequestOptions requestOptions) { final String contentType = "application/json"; final String accept = "application/json"; return FluxUtil.withContext( context -> service.createOrReplaceTopic(this.getEndpoint(), this.getServiceVersion().getVersion(), - this.getHub(), roomId, topicId, contentType, accept, resource, requestOptions, context)); + this.getHub(), roomId, topicId, contentType, accept, topic, requestOptions, context)); } /** @@ -2608,7 +2624,7 @@ public Mono> createOrReplaceTopicWithResponseAsync(String r * * @param roomId Room identifier. * @param topicId Topic identifier unique within the room. - * @param resource The resource instance. + * @param topic The resource instance. * @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. @@ -2617,12 +2633,12 @@ public Mono> createOrReplaceTopicWithResponseAsync(String r * @return represents a chat topic in a room along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response createOrReplaceTopicWithResponse(String roomId, String topicId, BinaryData resource, + public Response createOrReplaceTopicWithResponse(String roomId, String topicId, BinaryData topic, RequestOptions requestOptions) { final String contentType = "application/json"; final String accept = "application/json"; return service.createOrReplaceTopicSync(this.getEndpoint(), this.getServiceVersion().getVersion(), - this.getHub(), roomId, topicId, contentType, accept, resource, requestOptions, Context.NONE); + this.getHub(), roomId, topicId, contentType, accept, topic, requestOptions, Context.NONE); } /** @@ -2742,7 +2758,7 @@ public Response getTopicWithResponse(String roomId, String topicId, * * @param roomId Room identifier. * @param topicId Topic identifier unique within the room. - * @param resource The resource instance. + * @param topic The resource instance. * @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. @@ -2751,13 +2767,13 @@ public Response getTopicWithResponse(String roomId, String topicId, * @return represents a chat topic in a room along with {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> updateTopicWithResponseAsync(String roomId, String topicId, BinaryData resource, + public Mono> updateTopicWithResponseAsync(String roomId, String topicId, BinaryData topic, RequestOptions requestOptions) { final String contentType = "application/merge-patch+json"; final String accept = "application/json"; return FluxUtil .withContext(context -> service.updateTopic(this.getEndpoint(), this.getServiceVersion().getVersion(), - this.getHub(), roomId, topicId, contentType, accept, resource, requestOptions, context)); + this.getHub(), roomId, topicId, contentType, accept, topic, requestOptions, context)); } /** @@ -2808,7 +2824,7 @@ public Mono> updateTopicWithResponseAsync(String roomId, St * * @param roomId Room identifier. * @param topicId Topic identifier unique within the room. - * @param resource The resource instance. + * @param topic The resource instance. * @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. @@ -2817,12 +2833,12 @@ public Mono> updateTopicWithResponseAsync(String roomId, St * @return represents a chat topic in a room along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response updateTopicWithResponse(String roomId, String topicId, BinaryData resource, + public Response updateTopicWithResponse(String roomId, String topicId, BinaryData topic, RequestOptions requestOptions) { final String contentType = "application/merge-patch+json"; final String accept = "application/json"; return service.updateTopicSync(this.getEndpoint(), this.getServiceVersion().getVersion(), this.getHub(), roomId, - topicId, contentType, accept, resource, requestOptions, Context.NONE); + topicId, contentType, accept, topic, requestOptions, Context.NONE); } /** @@ -3123,7 +3139,7 @@ public PagedIterable listRoomMembers(String roomId, RequestOptions r * * @param roomId Room identifier. * @param userId User ID of the member. - * @param resource The resource instance. + * @param member The resource instance. * @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. @@ -3133,12 +3149,12 @@ public PagedIterable listRoomMembers(String roomId, RequestOptions r */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> createOrReplaceRoomMemberWithResponseAsync(String roomId, String userId, - BinaryData resource, RequestOptions requestOptions) { + BinaryData member, RequestOptions requestOptions) { final String contentType = "application/json"; final String accept = "application/json"; return FluxUtil.withContext( context -> service.createOrReplaceRoomMember(this.getEndpoint(), this.getServiceVersion().getVersion(), - this.getHub(), roomId, userId, contentType, accept, resource, requestOptions, context)); + this.getHub(), roomId, userId, contentType, accept, member, requestOptions, context)); } /** @@ -3184,7 +3200,7 @@ public Mono> createOrReplaceRoomMemberWithResponseAsync(Str * * @param roomId Room identifier. * @param userId User ID of the member. - * @param resource The resource instance. + * @param member The resource instance. * @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. @@ -3193,12 +3209,12 @@ public Mono> createOrReplaceRoomMemberWithResponseAsync(Str * @return represents a room member along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response createOrReplaceRoomMemberWithResponse(String roomId, String userId, BinaryData resource, + public Response createOrReplaceRoomMemberWithResponse(String roomId, String userId, BinaryData member, RequestOptions requestOptions) { final String contentType = "application/json"; final String accept = "application/json"; return service.createOrReplaceRoomMemberSync(this.getEndpoint(), this.getServiceVersion().getVersion(), - this.getHub(), roomId, userId, contentType, accept, resource, requestOptions, Context.NONE); + this.getHub(), roomId, userId, contentType, accept, member, requestOptions, Context.NONE); } /** @@ -3573,7 +3589,7 @@ public Response getUserWithResponse(String userId, RequestOptions re * * * @param userId User identifier. - * @param resource The resource instance. + * @param user The resource instance. * @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. @@ -3583,13 +3599,13 @@ public Response getUserWithResponse(String userId, RequestOptions re * {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> createOrReplaceUserWithResponseAsync(String userId, BinaryData resource, + public Mono> createOrReplaceUserWithResponseAsync(String userId, BinaryData user, RequestOptions requestOptions) { final String contentType = "application/json"; final String accept = "application/json"; return FluxUtil.withContext( context -> service.createOrReplaceUser(this.getEndpoint(), this.getServiceVersion().getVersion(), - this.getHub(), userId, contentType, accept, resource, requestOptions, context)); + this.getHub(), userId, contentType, accept, user, requestOptions, context)); } /** @@ -3639,7 +3655,7 @@ public Mono> createOrReplaceUserWithResponseAsync(String us * * * @param userId User identifier. - * @param resource The resource instance. + * @param user The resource instance. * @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. @@ -3648,12 +3664,12 @@ public Mono> createOrReplaceUserWithResponseAsync(String us * @return represents a user profile in the chat system along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response createOrReplaceUserWithResponse(String userId, BinaryData resource, + public Response createOrReplaceUserWithResponse(String userId, BinaryData user, RequestOptions requestOptions) { final String contentType = "application/json"; final String accept = "application/json"; return service.createOrReplaceUserSync(this.getEndpoint(), this.getServiceVersion().getVersion(), this.getHub(), - userId, contentType, accept, resource, requestOptions, Context.NONE); + userId, contentType, accept, user, requestOptions, Context.NONE); } /** diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/ChatConversation.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/ChatConversation.java index d3bc442f97ed3..9f4102abb90e6 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/ChatConversation.java +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/ChatConversation.java @@ -23,12 +23,6 @@ public final class ChatConversation implements JsonSerializable { String id = null; - String parentRoom = null; + String roomId = null; String etag = null; while (reader.nextToken() != JsonToken.END_OBJECT) { String fieldName = reader.getFieldName(); @@ -107,17 +91,33 @@ public static ChatConversation fromJson(JsonReader jsonReader) throws IOExceptio if ("id".equals(fieldName)) { id = reader.getString(); } else if ("parentRoom".equals(fieldName)) { - parentRoom = reader.getString(); + roomId = reader.getString(); } else if ("etag".equals(fieldName)) { etag = reader.getString(); } else { reader.skipChildren(); } } - ChatConversation deserializedChatConversation = new ChatConversation(parentRoom); + ChatConversation deserializedChatConversation = new ChatConversation(roomId); deserializedChatConversation.id = id; deserializedChatConversation.etag = etag; return deserializedChatConversation; }); } + + /* + * Parent room identifier. + */ + @Generated + private final String roomId; + + /** + * Get the roomId property: Parent room identifier. + * + * @return the roomId value. + */ + @Generated + public String getRoomId() { + return this.roomId; + } } diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/GetClientAccessTokenOptions.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/ClientAccessTokenOptions.java similarity index 53% rename from sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/GetClientAccessTokenOptions.java rename to sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/ClientAccessTokenOptions.java index d09f7873b8e1e..43555ae692f68 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/GetClientAccessTokenOptions.java +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/ClientAccessTokenOptions.java @@ -5,22 +5,28 @@ import java.time.Duration; -/** Options for creating a Web PubSub client access token for Chat. */ -public final class GetClientAccessTokenOptions { +/** + * Options for creating a client access token used to connect to Azure Web PubSub Chat. + * The token can identify a user and has a configurable lifetime, which defaults to one hour. + * Clients authenticated with an access key sign the token locally; clients authenticated with + * Microsoft Entra ID request the token from the service. + */ +public final class ClientAccessTokenOptions { private Duration expiresAfter = Duration.ofHours(1); private String userId; - /** Creates an instance of {@link GetClientAccessTokenOptions}. */ - public GetClientAccessTokenOptions() { + /** Creates an instance of {@link ClientAccessTokenOptions}. */ + public ClientAccessTokenOptions() { } /** * Sets the duration after which the client access token expires. * - * @param expiresAfter The token lifetime. + * @param expiresAfter The token lifetime. Must be at least one minute and at most + * {@link Integer#MAX_VALUE} minutes. Fractional minutes are truncated when requesting a token from the service. * @return The updated options. */ - public GetClientAccessTokenOptions setExpiresAfter(Duration expiresAfter) { + public ClientAccessTokenOptions setExpiresAfter(Duration expiresAfter) { this.expiresAfter = expiresAfter; return this; } @@ -28,7 +34,7 @@ public GetClientAccessTokenOptions setExpiresAfter(Duration expiresAfter) { /** * Gets the duration after which the client access token expires. * - * @return The token lifetime. + * @return The token lifetime, which defaults to one hour. */ public Duration getExpiresAfter() { return expiresAfter; @@ -40,7 +46,7 @@ public Duration getExpiresAfter() { * @param userId The user ID. * @return The updated options. */ - public GetClientAccessTokenOptions setUserId(String userId) { + public ClientAccessTokenOptions setUserId(String userId) { this.userId = userId; return this; } diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/MessageContent.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/MessageContent.java index d71498aaa3da3..f746d69943cc1 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/MessageContent.java +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/MessageContent.java @@ -18,6 +18,8 @@ /** * Message content containing exactly one of text or binary data. * Use {@link #fromText(String)} or {@link #fromBinary(byte[])} to create content. + * Text and binary are independent content types, not alternate encodings of the same value. + * Binary data is base64 encoded on the wire. No conversion between text and binary is performed. * The getter for the unselected representation returns {@code null}. */ @Immutable diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/resources/META-INF/azure-messaging-webpubsub-chat_metadata.json b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/resources/META-INF/azure-messaging-webpubsub-chat_metadata.json index 6947686b8ae8a..26bdd302713db 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/resources/META-INF/azure-messaging-webpubsub-chat_metadata.json +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/resources/META-INF/azure-messaging-webpubsub-chat_metadata.json @@ -1 +1 @@ -{"flavor":"azure","apiVersions":{"WebPubSubChat":"2026-08-01-preview"},"crossLanguagePackageId":"WebPubSubChat","crossLanguageVersion":"9db8b5aee1c7","crossLanguageDefinitions":{"com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient":"Customizations.WebPubSubChatServiceClient","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceRole":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceRoleWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceRoom":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceRoomMember":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoomMember","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceRoomMemberWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoomMember","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceRoomWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceTopic":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceTopicWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceUser":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceUserWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteMessage":"WebPubSubChat.WebPubSubChatServiceClient.deleteMessage","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteMessageWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteMessage","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteRole":"WebPubSubChat.WebPubSubChatServiceClient.deleteRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteRoleWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteRoom":"WebPubSubChat.WebPubSubChatServiceClient.deleteRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteRoomMember":"WebPubSubChat.WebPubSubChatServiceClient.deleteRoomMember","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteRoomMemberWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteRoomMember","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteRoomWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteTopic":"WebPubSubChat.WebPubSubChatServiceClient.deleteTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteTopicWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteUser":"WebPubSubChat.WebPubSubChatServiceClient.deleteUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteUserWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.generateClientToken":"Customizations.WebPubSubChatServiceClient.generateClientToken","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.generateClientTokenWithResponse":"Customizations.WebPubSubChatServiceClient.generateClientToken","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getConversation":"WebPubSubChat.WebPubSubChatServiceClient.getConversation","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getConversationWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getConversation","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getRole":"WebPubSubChat.WebPubSubChatServiceClient.getRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getRoleWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getRoom":"WebPubSubChat.WebPubSubChatServiceClient.getRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getRoomWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getTopic":"WebPubSubChat.WebPubSubChatServiceClient.getTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getTopicWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getUser":"WebPubSubChat.WebPubSubChatServiceClient.getUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getUserWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.listMessages":"WebPubSubChat.WebPubSubChatServiceClient.listMessages","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.listRoles":"WebPubSubChat.WebPubSubChatServiceClient.listRoles","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.listRoomMembers":"WebPubSubChat.WebPubSubChatServiceClient.listRoomMembers","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.listRooms":"WebPubSubChat.WebPubSubChatServiceClient.listRooms","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.listRoomsForUser":"WebPubSubChat.WebPubSubChatServiceClient.listRoomsForUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.listTopics":"WebPubSubChat.WebPubSubChatServiceClient.listTopics","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.listUsers":"WebPubSubChat.WebPubSubChatServiceClient.listUsers","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.updateMessage":"WebPubSubChat.WebPubSubChatServiceClient.updateMessage","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.updateMessageWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.updateMessage","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.updateTopic":"WebPubSubChat.WebPubSubChatServiceClient.updateTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.updateTopicWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.updateTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient":"Customizations.WebPubSubChatServiceClient","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceRole":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceRoleWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceRoom":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceRoomMember":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoomMember","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceRoomMemberWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoomMember","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceRoomWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceTopic":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceTopicWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceUser":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceUserWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteMessage":"WebPubSubChat.WebPubSubChatServiceClient.deleteMessage","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteMessageWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteMessage","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteRole":"WebPubSubChat.WebPubSubChatServiceClient.deleteRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteRoleWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteRoom":"WebPubSubChat.WebPubSubChatServiceClient.deleteRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteRoomMember":"WebPubSubChat.WebPubSubChatServiceClient.deleteRoomMember","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteRoomMemberWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteRoomMember","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteRoomWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteTopic":"WebPubSubChat.WebPubSubChatServiceClient.deleteTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteTopicWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteUser":"WebPubSubChat.WebPubSubChatServiceClient.deleteUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteUserWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.generateClientToken":"Customizations.WebPubSubChatServiceClient.generateClientToken","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.generateClientTokenWithResponse":"Customizations.WebPubSubChatServiceClient.generateClientToken","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getConversation":"WebPubSubChat.WebPubSubChatServiceClient.getConversation","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getConversationWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getConversation","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getRole":"WebPubSubChat.WebPubSubChatServiceClient.getRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getRoleWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getRoom":"WebPubSubChat.WebPubSubChatServiceClient.getRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getRoomWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getTopic":"WebPubSubChat.WebPubSubChatServiceClient.getTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getTopicWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getUser":"WebPubSubChat.WebPubSubChatServiceClient.getUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getUserWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.listMessages":"WebPubSubChat.WebPubSubChatServiceClient.listMessages","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.listRoles":"WebPubSubChat.WebPubSubChatServiceClient.listRoles","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.listRoomMembers":"WebPubSubChat.WebPubSubChatServiceClient.listRoomMembers","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.listRooms":"WebPubSubChat.WebPubSubChatServiceClient.listRooms","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.listRoomsForUser":"WebPubSubChat.WebPubSubChatServiceClient.listRoomsForUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.listTopics":"WebPubSubChat.WebPubSubChatServiceClient.listTopics","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.listUsers":"WebPubSubChat.WebPubSubChatServiceClient.listUsers","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.updateMessage":"WebPubSubChat.WebPubSubChatServiceClient.updateMessage","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.updateMessageWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.updateMessage","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.updateTopic":"WebPubSubChat.WebPubSubChatServiceClient.updateTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.updateTopicWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.updateTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClientBuilder":"Customizations.WebPubSubChatServiceClient","com.azure.messaging.webpubsub.chat.implementation.models.GenerateClientTokenResponse":"Customizations.GenerateClientTokenResponse","com.azure.messaging.webpubsub.chat.models.ChatConversation":"WebPubSubChat.ChatConversation","com.azure.messaging.webpubsub.chat.models.ChatMessage":"WebPubSubChat.ChatMessage","com.azure.messaging.webpubsub.chat.models.ChatPermission":"WebPubSubChat.ChatPermission","com.azure.messaging.webpubsub.chat.models.ChatRole":"WebPubSubChat.ChatRole","com.azure.messaging.webpubsub.chat.models.ChatRoom":"WebPubSubChat.ChatRoom","com.azure.messaging.webpubsub.chat.models.ChatRoomMember":"WebPubSubChat.ChatRoomMember","com.azure.messaging.webpubsub.chat.models.ChatTopic":"WebPubSubChat.ChatTopic","com.azure.messaging.webpubsub.chat.models.ChatTopicState":"WebPubSubChat.ChatTopicState","com.azure.messaging.webpubsub.chat.models.ChatUser":"WebPubSubChat.ChatUser","com.azure.messaging.webpubsub.chat.models.ChatUserKind":"WebPubSubChat.ChatUserKind","com.azure.messaging.webpubsub.chat.models.ChatUserRoom":"WebPubSubChat.ChatUserRoom","com.azure.messaging.webpubsub.chat.models.HumanChatUser":"WebPubSubChat.HumanChatUser","com.azure.messaging.webpubsub.chat.models.MessageContent":"WebPubSubChat.MessageContent"},"generatedFiles":["src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceAsyncClient.java","src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceClient.java","src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceClientBuilder.java","src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceVersion.java","src/main/java/com/azure/messaging/webpubsub/chat/implementation/JsonMergePatchHelper.java","src/main/java/com/azure/messaging/webpubsub/chat/implementation/WebPubSubChatServiceClientImpl.java","src/main/java/com/azure/messaging/webpubsub/chat/implementation/models/GenerateClientTokenResponse.java","src/main/java/com/azure/messaging/webpubsub/chat/implementation/models/package-info.java","src/main/java/com/azure/messaging/webpubsub/chat/implementation/package-info.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatConversation.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatMessage.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatPermission.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatRole.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatRoom.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatRoomMember.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatTopic.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatTopicState.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatUser.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatUserKind.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatUserRoom.java","src/main/java/com/azure/messaging/webpubsub/chat/models/HumanChatUser.java","src/main/java/com/azure/messaging/webpubsub/chat/models/MessageContent.java","src/main/java/com/azure/messaging/webpubsub/chat/models/package-info.java","src/main/java/com/azure/messaging/webpubsub/chat/package-info.java","src/main/java/module-info.java"]} \ No newline at end of file +{"flavor":"azure","apiVersions":{"WebPubSubChat":"2026-08-01-preview"},"crossLanguagePackageId":"WebPubSubChat","crossLanguageVersion":"32d235898555","crossLanguageDefinitions":{"com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient":"Customizations.WebPubSubChatServiceClient","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceRole":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceRoleWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceRoom":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceRoomMember":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoomMember","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceRoomMemberWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoomMember","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceRoomWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceTopic":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceTopicWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceUser":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceUserWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteMessage":"WebPubSubChat.WebPubSubChatServiceClient.deleteMessage","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteMessageWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteMessage","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteRole":"WebPubSubChat.WebPubSubChatServiceClient.deleteRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteRoleWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteRoom":"WebPubSubChat.WebPubSubChatServiceClient.deleteRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteRoomMember":"WebPubSubChat.WebPubSubChatServiceClient.deleteRoomMember","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteRoomMemberWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteRoomMember","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteRoomWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteTopic":"WebPubSubChat.WebPubSubChatServiceClient.deleteTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteTopicWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteUser":"WebPubSubChat.WebPubSubChatServiceClient.deleteUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteUserWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.generateClientToken":"Customizations.WebPubSubChatServiceClient.generateClientToken","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.generateClientTokenWithResponse":"Customizations.WebPubSubChatServiceClient.generateClientToken","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getConversation":"WebPubSubChat.WebPubSubChatServiceClient.getConversation","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getConversationWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getConversation","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getRole":"WebPubSubChat.WebPubSubChatServiceClient.getRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getRoleWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getRoom":"WebPubSubChat.WebPubSubChatServiceClient.getRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getRoomWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getTopic":"WebPubSubChat.WebPubSubChatServiceClient.getTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getTopicWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getUser":"WebPubSubChat.WebPubSubChatServiceClient.getUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getUserWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.listMessages":"WebPubSubChat.WebPubSubChatServiceClient.listMessages","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.listRoles":"WebPubSubChat.WebPubSubChatServiceClient.listRoles","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.listRoomMembers":"WebPubSubChat.WebPubSubChatServiceClient.listRoomMembers","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.listRooms":"WebPubSubChat.WebPubSubChatServiceClient.listRooms","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.listRoomsForUser":"WebPubSubChat.WebPubSubChatServiceClient.listRoomsForUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.listTopics":"WebPubSubChat.WebPubSubChatServiceClient.listTopics","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.listUsers":"WebPubSubChat.WebPubSubChatServiceClient.listUsers","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.updateMessage":"WebPubSubChat.WebPubSubChatServiceClient.updateMessage","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.updateMessageWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.updateMessage","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.updateTopic":"WebPubSubChat.WebPubSubChatServiceClient.updateTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.updateTopicWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.updateTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient":"Customizations.WebPubSubChatServiceClient","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceRole":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceRoleWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceRoom":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceRoomMember":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoomMember","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceRoomMemberWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoomMember","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceRoomWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceTopic":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceTopicWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceUser":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceUserWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteMessage":"WebPubSubChat.WebPubSubChatServiceClient.deleteMessage","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteMessageWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteMessage","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteRole":"WebPubSubChat.WebPubSubChatServiceClient.deleteRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteRoleWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteRoom":"WebPubSubChat.WebPubSubChatServiceClient.deleteRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteRoomMember":"WebPubSubChat.WebPubSubChatServiceClient.deleteRoomMember","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteRoomMemberWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteRoomMember","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteRoomWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteTopic":"WebPubSubChat.WebPubSubChatServiceClient.deleteTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteTopicWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteUser":"WebPubSubChat.WebPubSubChatServiceClient.deleteUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteUserWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.generateClientToken":"Customizations.WebPubSubChatServiceClient.generateClientToken","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.generateClientTokenWithResponse":"Customizations.WebPubSubChatServiceClient.generateClientToken","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getConversation":"WebPubSubChat.WebPubSubChatServiceClient.getConversation","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getConversationWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getConversation","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getRole":"WebPubSubChat.WebPubSubChatServiceClient.getRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getRoleWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getRoom":"WebPubSubChat.WebPubSubChatServiceClient.getRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getRoomWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getTopic":"WebPubSubChat.WebPubSubChatServiceClient.getTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getTopicWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getUser":"WebPubSubChat.WebPubSubChatServiceClient.getUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getUserWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.listMessages":"WebPubSubChat.WebPubSubChatServiceClient.listMessages","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.listRoles":"WebPubSubChat.WebPubSubChatServiceClient.listRoles","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.listRoomMembers":"WebPubSubChat.WebPubSubChatServiceClient.listRoomMembers","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.listRooms":"WebPubSubChat.WebPubSubChatServiceClient.listRooms","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.listRoomsForUser":"WebPubSubChat.WebPubSubChatServiceClient.listRoomsForUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.listTopics":"WebPubSubChat.WebPubSubChatServiceClient.listTopics","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.listUsers":"WebPubSubChat.WebPubSubChatServiceClient.listUsers","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.updateMessage":"WebPubSubChat.WebPubSubChatServiceClient.updateMessage","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.updateMessageWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.updateMessage","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.updateTopic":"WebPubSubChat.WebPubSubChatServiceClient.updateTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.updateTopicWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.updateTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClientBuilder":"Customizations.WebPubSubChatServiceClient","com.azure.messaging.webpubsub.chat.implementation.models.GenerateClientTokenResponse":"Customizations.GenerateClientTokenResponse","com.azure.messaging.webpubsub.chat.models.ChatConversation":"WebPubSubChat.ChatConversation","com.azure.messaging.webpubsub.chat.models.ChatMessage":"WebPubSubChat.ChatMessage","com.azure.messaging.webpubsub.chat.models.ChatPermission":"WebPubSubChat.ChatPermission","com.azure.messaging.webpubsub.chat.models.ChatRole":"WebPubSubChat.ChatRole","com.azure.messaging.webpubsub.chat.models.ChatRoom":"WebPubSubChat.ChatRoom","com.azure.messaging.webpubsub.chat.models.ChatRoomMember":"WebPubSubChat.ChatRoomMember","com.azure.messaging.webpubsub.chat.models.ChatTopic":"WebPubSubChat.ChatTopic","com.azure.messaging.webpubsub.chat.models.ChatTopicState":"WebPubSubChat.ChatTopicState","com.azure.messaging.webpubsub.chat.models.ChatUser":"WebPubSubChat.ChatUser","com.azure.messaging.webpubsub.chat.models.ChatUserKind":"WebPubSubChat.ChatUserKind","com.azure.messaging.webpubsub.chat.models.ChatUserRoom":"WebPubSubChat.ChatUserRoom","com.azure.messaging.webpubsub.chat.models.HumanChatUser":"WebPubSubChat.HumanChatUser","com.azure.messaging.webpubsub.chat.models.MessageContent":"WebPubSubChat.MessageContent"},"generatedFiles":["src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceAsyncClient.java","src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceClient.java","src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceClientBuilder.java","src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceVersion.java","src/main/java/com/azure/messaging/webpubsub/chat/implementation/JsonMergePatchHelper.java","src/main/java/com/azure/messaging/webpubsub/chat/implementation/WebPubSubChatServiceClientImpl.java","src/main/java/com/azure/messaging/webpubsub/chat/implementation/models/GenerateClientTokenResponse.java","src/main/java/com/azure/messaging/webpubsub/chat/implementation/models/package-info.java","src/main/java/com/azure/messaging/webpubsub/chat/implementation/package-info.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatConversation.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatMessage.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatPermission.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatRole.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatRoom.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatRoomMember.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatTopic.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatTopicState.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatUser.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatUserKind.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatUserRoom.java","src/main/java/com/azure/messaging/webpubsub/chat/models/HumanChatUser.java","src/main/java/com/azure/messaging/webpubsub/chat/models/MessageContent.java","src/main/java/com/azure/messaging/webpubsub/chat/models/package-info.java","src/main/java/com/azure/messaging/webpubsub/chat/package-info.java","src/main/java/module-info.java"]} \ No newline at end of file diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/samples/java/com/azure/messaging/webpubsub/chat/WebPubSubChatSamples.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/samples/java/com/azure/messaging/webpubsub/chat/WebPubSubChatSamples.java index ecc433414f351..fe4a6af5c5b56 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/samples/java/com/azure/messaging/webpubsub/chat/WebPubSubChatSamples.java +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/samples/java/com/azure/messaging/webpubsub/chat/WebPubSubChatSamples.java @@ -13,7 +13,7 @@ import com.azure.messaging.webpubsub.chat.models.ChatRoomMember; import com.azure.messaging.webpubsub.chat.models.ChatTopic; import com.azure.messaging.webpubsub.chat.models.ChatTopicState; -import com.azure.messaging.webpubsub.chat.models.GetClientAccessTokenOptions; +import com.azure.messaging.webpubsub.chat.models.ClientAccessTokenOptions; import com.azure.messaging.webpubsub.chat.models.HumanChatUser; import com.azure.messaging.webpubsub.chat.models.MessageContent; import com.azure.messaging.webpubsub.chat.models.WebPubSubClientAccessToken; @@ -71,7 +71,7 @@ public void getClientAccessToken() { // BEGIN: readme-sample-getChatClientAccessToken WebPubSubClientAccessToken accessToken = client.getClientAccessToken( - new GetClientAccessTokenOptions().setUserId("alice").setExpiresAfter(Duration.ofHours(1))); + new ClientAccessTokenOptions().setUserId("alice").setExpiresAfter(Duration.ofHours(1))); String clientConnectionUrl = accessToken.getUrl(); // END: readme-sample-getChatClientAccessToken } diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/ChatServiceClientLiveTests.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/ChatServiceClientLiveTests.java index a7a527e1efcd3..165eccbf5efb4 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/ChatServiceClientLiveTests.java +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/ChatServiceClientLiveTests.java @@ -19,7 +19,7 @@ import com.azure.messaging.webpubsub.chat.models.ChatTopicState; import com.azure.messaging.webpubsub.chat.models.ChatUser; import com.azure.messaging.webpubsub.chat.models.ChatUserRoom; -import com.azure.messaging.webpubsub.chat.models.GetClientAccessTokenOptions; +import com.azure.messaging.webpubsub.chat.models.ClientAccessTokenOptions; import com.azure.messaging.webpubsub.chat.models.HumanChatUser; import com.azure.messaging.webpubsub.chat.models.MessageContent; import com.azure.messaging.webpubsub.chat.models.WebPubSubClientAccessToken; @@ -327,7 +327,7 @@ public void canManageRoomsAndReadEmptyConversation() { ChatConversation conversation = execute(() -> client.getConversation(createdRoom.getDefaultConversation()), () -> asyncClient.getConversation(createdRoom.getDefaultConversation())); assertEquals(createdRoom.getDefaultConversation(), conversation.getId()); - assertEquals(roomId, conversation.getParentRoom()); + assertEquals(roomId, conversation.getRoomId()); assertFalse(execute(() -> client.listMessages(conversation.getId()).stream().findAny().isPresent(), () -> asyncClient.listMessages(conversation.getId()).hasElements())); assertFalse(execute(() -> client.listRoomMembers(roomId).stream().findAny().isPresent(), @@ -399,8 +399,8 @@ public void canListUpdateAndDeleteMessages() { new ChatRoomMember(BuiltInChatRoles.ROOM_MEMBER))); WebPubSubClientAccessToken accessToken - = execute(() -> entraClient.getClientAccessToken(new GetClientAccessTokenOptions().setUserId(userId)), - () -> entraAsyncClient.getClientAccessToken(new GetClientAccessTokenOptions().setUserId(userId))); + = execute(() -> entraClient.getClientAccessToken(new ClientAccessTokenOptions().setUserId(userId)), + () -> entraAsyncClient.getClientAccessToken(new ClientAccessTokenOptions().setUserId(userId))); assertNotNull(accessToken.getToken()); assertNotNull(accessToken.getUrl()); diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/MessageContentTests.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/MessageContentTests.java index 6f546dfb75a62..48d64233a984c 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/MessageContentTests.java +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/MessageContentTests.java @@ -8,6 +8,7 @@ import com.azure.core.http.HttpRequest; import com.azure.core.test.http.MockHttpResponse; import com.azure.core.test.utils.MockTokenCredential; +import com.azure.core.util.BinaryData; import com.azure.json.JsonProviders; import com.azure.json.JsonReader; import com.azure.json.JsonSerializable; @@ -155,6 +156,34 @@ public void syncAndAsyncUpdatesSendOnlySelectedContent(boolean async) throws IOE sentRequest.get().getHeaders().getValue(HttpHeaderName.CONTENT_TYPE)); } + @ParameterizedTest + @ValueSource(booleans = { false, true }) + public void updatesUsePathMessageIdNotReadOnlyModelId(boolean async) { + AtomicReference sentRequest = new AtomicReference<>(); + String response = "{\"id\":\"2\",\"content\":{\"text\":\"updated\"}}"; + WebPubSubChatServiceClientBuilder builder + = new WebPubSubChatServiceClientBuilder().endpoint("https://example.webpubsub.azure.com") + .hub("chat") + .credential(new MockTokenCredential()) + .httpClient(request -> { + sentRequest.set(request); + return Mono.just(new MockHttpResponse(request, 200, + new HttpHeaders().set(HttpHeaderName.CONTENT_TYPE, "application/json"), + response.getBytes(StandardCharsets.UTF_8))); + }); + ChatMessage message = BinaryData.fromString("{\"id\":\"1\",\"content\":{\"text\":\"original\"}}") + .toObject(ChatMessage.class) + .setContent(MessageContent.fromText("updated")); + ChatMessage result = async + ? builder.buildAsyncClient().updateMessage("c.room.default", "2", message).block() + : builder.buildClient().updateMessage("c.room.default", "2", message); + + assertEquals("2", result.getId()); + assertEquals("/api/hubs/chat/chat/conversations/c.room.default/messages/2", + sentRequest.get().getUrl().getPath()); + assertEquals("{\"content\":{\"text\":\"updated\"}}", sentRequest.get().getBodyAsBinaryData().toString()); + } + private static MessageContent deserialize(String json) throws IOException { try (JsonReader reader = JsonProviders.createReader(json)) { return MessageContent.fromJson(reader); diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/WebPubSubChatClientAccessTokenTests.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/WebPubSubChatClientAccessTokenTests.java index 3526f81a2f3dd..89ab98b8352ec 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/WebPubSubChatClientAccessTokenTests.java +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/WebPubSubChatClientAccessTokenTests.java @@ -8,7 +8,7 @@ import com.azure.core.http.HttpRequest; import com.azure.core.test.http.MockHttpResponse; import com.azure.core.test.utils.MockTokenCredential; -import com.azure.messaging.webpubsub.chat.models.GetClientAccessTokenOptions; +import com.azure.messaging.webpubsub.chat.models.ClientAccessTokenOptions; import com.azure.messaging.webpubsub.chat.models.WebPubSubClientAccessToken; import com.nimbusds.jwt.JWTClaimsSet; import com.nimbusds.jwt.SignedJWT; @@ -42,7 +42,7 @@ public void keyCredentialGeneratesChatTokenLocally() throws ParseException { Instant before = Instant.now(); WebPubSubClientAccessToken token - = client.getClientAccessToken(new GetClientAccessTokenOptions().setUserId("alice")); + = client.getClientAccessToken(new ClientAccessTokenOptions().setUserId("alice")); assertNotNull(token.getToken()); assertEquals("wss://example.webpubsub.azure.com/client/hubs/chat?access_token=" + token.getToken(), @@ -64,7 +64,7 @@ public void asyncKeyCredentialUsesSameTokenSemantics() throws ParseException { .buildAsyncClient(); WebPubSubClientAccessToken token - = client.getClientAccessToken(new GetClientAccessTokenOptions().setUserId("alice")).block(); + = client.getClientAccessToken(new ClientAccessTokenOptions().setUserId("alice")).block(); assertNotNull(token); JWTClaimsSet claims = SignedJWT.parse(token.getToken()).getJWTClaimsSet(); @@ -80,7 +80,7 @@ public void connectionStringGeneratesTokenLocally() { .httpClient(request -> Mono.error(new AssertionError("Local token generation must not send a request."))) .buildClient(); - WebPubSubClientAccessToken token = client.getClientAccessToken(new GetClientAccessTokenOptions()); + WebPubSubClientAccessToken token = client.getClientAccessToken(new ClientAccessTokenOptions()); assertTrue(token.getUrl().startsWith("wss://example.webpubsub.azure.com:8443/client/hubs/chat?access_token=")); } @@ -92,7 +92,7 @@ public void signingFailureReturnsNullToken() { .credential(new AzureKeyCredential("short-key")) .buildClient(); - WebPubSubClientAccessToken token = client.getClientAccessToken(new GetClientAccessTokenOptions()); + WebPubSubClientAccessToken token = client.getClientAccessToken(new ClientAccessTokenOptions()); assertNull(token.getToken()); assertEquals("wss://example.webpubsub.azure.com/client/hubs/chat?access_token=null", token.getUrl()); @@ -104,7 +104,7 @@ public void tokenCredentialCallsGenerateTokenOperation() { WebPubSubChatServiceClient client = createTokenCredentialClient(sentRequest, null); WebPubSubClientAccessToken token = client.getClientAccessToken( - new GetClientAccessTokenOptions().setUserId("alice").setExpiresAfter(Duration.ofMinutes(30))); + new ClientAccessTokenOptions().setUserId("alice").setExpiresAfter(Duration.ofMinutes(30))); assertEquals("server-token", token.getToken()); assertEquals("wss://example.webpubsub.azure.com/client/hubs/chat?access_token=server-token", token.getUrl()); @@ -133,7 +133,7 @@ public void asyncTokenCredentialCallsGenerateTokenOperation() { .buildAsyncClient(); WebPubSubClientAccessToken token - = client.getClientAccessToken(new GetClientAccessTokenOptions().setUserId("alice")).block(); + = client.getClientAccessToken(new ClientAccessTokenOptions().setUserId("alice")).block(); assertNotNull(token); assertEquals("server-token", token.getToken()); @@ -147,7 +147,7 @@ public void tokenCredentialUsesReverseProxyForGenerateTokenOperation() { AtomicReference sentRequest = new AtomicReference<>(); WebPubSubChatServiceClient client = createTokenCredentialClient(sentRequest, "https://proxy.example/gateway"); - client.getClientAccessToken(new GetClientAccessTokenOptions()); + client.getClientAccessToken(new ClientAccessTokenOptions()); assertEquals("proxy.example", sentRequest.get().getUrl().getHost()); assertEquals("/gateway/api/hubs/chat/:generateToken", sentRequest.get().getUrl().getPath()); @@ -163,9 +163,9 @@ public void validatesTokenOptions() { assertThrows(NullPointerException.class, () -> client.getClientAccessToken(null)); assertThrows(NullPointerException.class, - () -> client.getClientAccessToken(new GetClientAccessTokenOptions().setExpiresAfter(null))); - assertThrows(IllegalArgumentException.class, () -> client - .getClientAccessToken(new GetClientAccessTokenOptions().setExpiresAfter(Duration.ofSeconds(59)))); + () -> client.getClientAccessToken(new ClientAccessTokenOptions().setExpiresAfter(null))); + assertThrows(IllegalArgumentException.class, + () -> client.getClientAccessToken(new ClientAccessTokenOptions().setExpiresAfter(Duration.ofSeconds(59)))); } private static WebPubSubChatServiceClient createTokenCredentialClient(AtomicReference sentRequest, diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/models/ChatConversationTests.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/models/ChatConversationTests.java new file mode 100644 index 0000000000000..a625c55433a84 --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/models/ChatConversationTests.java @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.messaging.webpubsub.chat.models; + +import com.azure.core.util.BinaryData; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class ChatConversationTests { + @Test + public void roomIdRetainsParentRoomWireName() { + ChatConversation conversation + = BinaryData.fromString("{\"id\":\"c.room.default\",\"parentRoom\":\"room\",\"etag\":\"etag\"}") + .toObject(ChatConversation.class); + + assertEquals("c.room.default", conversation.getId()); + assertEquals("room", conversation.getRoomId()); + assertEquals("etag", conversation.getEtag()); + assertEquals("{\"parentRoom\":\"room\"}", BinaryData.fromObject(conversation).toString()); + } +} diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/tsp-location.yaml b/sdk/webpubsub/azure-messaging-webpubsub-chat/tsp-location.yaml index 65a6151ea5d53..8e0ea00e7c45d 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/tsp-location.yaml +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/tsp-location.yaml @@ -1,4 +1,4 @@ directory: specification/webpubsub/data-plane/WebPubSubChat -commit: 44c2a4f48a4a2e4d77f9658749f990bcf9ab110f +commit: 03fa779a6c4ee641e12f63b73c8fdc5e35120156 repo: Azure/azure-rest-api-specs additionalDirectories: From 95e9aeb0590160917ec3fe5aa7bce2f4c6bdc2e4 Mon Sep 17 00:00:00 2001 From: Zitong Yang Date: Thu, 29 Oct 2026 02:01:20 -0700 Subject: [PATCH 13/18] Address Chat customization review feedback Remove customization-only tests and clarify topic creation versus partial updates. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .../azure-messaging-webpubsub-chat/README.md | 3 +- .../customization/pom.xml | 8 - .../main/java/WebPubSubChatCustomization.java | 7 - .../java/WebPubSubChatDocumentationTests.java | 233 ------------------ ...bChatMessageContentCustomizationTests.java | 70 ------ .../chat/WebPubSubChatServiceAsyncClient.java | 9 - .../chat/WebPubSubChatServiceClient.java | 9 - .../WebPubSubChatServiceClientImpl.java | 6 - .../webpubsub/chat/models/ChatTopic.java | 3 +- 9 files changed, 3 insertions(+), 345 deletions(-) delete mode 100644 sdk/webpubsub/azure-messaging-webpubsub-chat/customization/src/test/java/WebPubSubChatDocumentationTests.java delete mode 100644 sdk/webpubsub/azure-messaging-webpubsub-chat/customization/src/test/java/WebPubSubChatMessageContentCustomizationTests.java diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/README.md b/sdk/webpubsub/azure-messaging-webpubsub-chat/README.md index 4439b64b74820..d55d7c60c1253 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/README.md +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/README.md @@ -235,7 +235,8 @@ String conversationId = topic.getConversationId(); ``` When creating a topic, leave `state` unset (as above) or set it to -`ChatTopicState.NORMAL`. Other states are only valid when updating an existing topic. +`ChatTopicState.NORMAL`. Use `updateTopic` to change selected properties of an existing +topic instead of replacing it with `createOrReplaceTopic`. Use the returned conversation ID when a Chat WebSocket client sends messages to the topic. This server-side library manages resources and persisted messages; diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/pom.xml b/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/pom.xml index a2ccaa3d69013..ed513dc4792e2 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/pom.xml +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/pom.xml @@ -23,12 +23,4 @@ ../../../../ - - - org.junit.jupiter - junit-jupiter - 5.13.4 - test - - \ No newline at end of file diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/src/main/java/WebPubSubChatCustomization.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/src/main/java/WebPubSubChatCustomization.java index 4d9c93b969687..4b318b1e32c96 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/src/main/java/WebPubSubChatCustomization.java +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/src/main/java/WebPubSubChatCustomization.java @@ -99,13 +99,6 @@ static String correctLifecycleDocumentation(String source) { } corrected = corrected.substring(0, requestStart) + request + corrected.substring(responseStart); } - if (method.getNameAsString().startsWith("createOrReplaceTopic") - && !corrected.contains("When creating a topic, omit state")) { - corrected = corrected.replace("Create or replace a topic.", - "Create or replace a topic.\n *\n" - + " *

When creating a topic, omit state or set it to Normal. " - + "Other states are only valid when updating an existing topic.

"); - } if (!original.equals(corrected)) { source = source.replace(original, corrected); } diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/src/test/java/WebPubSubChatDocumentationTests.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/src/test/java/WebPubSubChatDocumentationTests.java deleted file mode 100644 index abc66afd11608..0000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/src/test/java/WebPubSubChatDocumentationTests.java +++ /dev/null @@ -1,233 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import com.github.javaparser.StaticJavaParser; -import com.github.javaparser.ast.body.MethodDeclaration; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.ValueSource; - -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.Arrays; -import java.util.List; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class WebPubSubChatDocumentationTests { - private static final String REQUEST = "

Request Body Schema

"; - private static final String RESPONSE = "

Response Body Schema

"; - private static final Path SOURCE - = Paths.get("..", "src", "main", "java", "com", "azure", "messaging", "webpubsub", "chat"); - - @Test - public void generatedDocumentationMatchesCustomization() throws IOException { - for (String file : Arrays.asList("WebPubSubChatServiceClient.java", "WebPubSubChatServiceAsyncClient.java", - "implementation/WebPubSubChatServiceClientImpl.java")) { - String source = new String(Files.readAllBytes(SOURCE.resolve(file)), StandardCharsets.UTF_8); - assertEquals(source, WebPubSubChatCustomization.correctLifecycleDocumentation(source), file); - } - } - - @Test - public void allWriteSchemasRespectVisibility() throws IOException { - for (String file : Arrays.asList("WebPubSubChatServiceClient.java", "WebPubSubChatServiceAsyncClient.java", - "implementation/WebPubSubChatServiceClientImpl.java")) { - List methods - = StaticJavaParser.parse(SOURCE.resolve(file)).findAll(MethodDeclaration.class); - int requests = 0; - for (MethodDeclaration method : methods) { - String doc = method.getJavadocComment().map(comment -> comment.getContent()).orElse(""); - if (doc.contains(RESPONSE)) { - assertFalse(doc.substring(doc.indexOf(RESPONSE)).contains("Optional, Required on create"), - method.getNameAsString()); - } - if (!doc.contains(REQUEST)) { - continue; - } - requests++; - String request = doc.substring(doc.indexOf(REQUEST), doc.indexOf(RESPONSE)); - assertFalse(request.contains("etag:"), method.getNameAsString()); - assertFalse(request.contains("Required on create"), method.getNameAsString()); - for (String readOnly : Arrays.asList("id:", "name:", "userId:", "createdAt:", "defaultConversation:", - "conversationId:")) { - assertFalse(java.util.regex.Pattern.compile("(?m)^\\h*\\*\\h+" + readOnly).matcher(request).find(), - method.getNameAsString() + ": " + readOnly); - } - String name = method.getNameAsString(); - if (name.startsWith("updateMessage")) { - assertTrue(request.contains("createdBy: String (Optional)")); - assertTrue(request.contains("content (Optional)")); - assertTrue(request.contains("text: String (Optional)")); - assertTrue(request.contains("binary: byte[] (Optional)")); - assertTrue(doc.substring(doc.indexOf(RESPONSE)).contains("content (Required)")); - } else if (name.startsWith("updateTopic") || name.startsWith("createOrReplaceTopic")) { - assertFalse(request.contains("createdBy:")); - assertTrue(request - .contains("title: String (" + (name.startsWith("update") ? "Optional" : "Required") + ")")); - assertTrue(request.contains("state: String(Normal/Archived/SoftDeleted) (Optional)")); - assertTrue(doc.substring(doc.indexOf(RESPONSE)).contains("title: String (Required)")); - assertTrue(doc.substring(doc.indexOf(RESPONSE)) - .contains("state: String(Normal/Archived/SoftDeleted) (Required)")); - } else if (name.startsWith("createOrReplaceRole")) { - assertTrue(request.contains("permissions (Required)")); - } else if (name.startsWith("createOrReplaceRoomMember")) { - assertTrue(request.contains("roleName: String (Required)")); - } else if (name.startsWith("createOrReplaceRoom")) { - assertTrue(request.contains("title: String (Required)")); - } else if (name.startsWith("createOrReplaceUser")) { - assertTrue(request.contains("kind: String(Human) (Required)")); - assertTrue(request.contains("nickname: String (Required)")); - } - assertTrue(doc.contains("@param resource")); - assertTrue(doc.contains("If-Match")); - } - assertEquals(file.startsWith("implementation") ? 14 : 7, requests, file); - } - } - - @Test - public void repairsEmitterDocumentationWithoutChangingCode() { - String source = "class Example {\n" + "/**\n * " + REQUEST + "\n" + " * id: String (Required)\n" - + " * title: String (Optional, Required on create)\n" - + " * state: String(Normal/Archived/SoftDeleted) (Optional, Required on create)\n" - + " * etag: String (Required)\n" + " * " + RESPONSE + "\n" + " * id: String (Required)\n" - + " * title: String (Optional, Required on create)\n" - + " * state: String(Normal/Archived/SoftDeleted) (Optional, Required on create)\n" - + " * @param roomId Room identifier.\n */\n" - + "public void updateTopicWithResponse(String roomId) { System.out.println(roomId); }\n}"; - String corrected = WebPubSubChatCustomization.correctLifecycleDocumentation(source); - assertFalse(corrected.equals(source)); - assertTrue(corrected.contains("title: String (Optional)")); - assertTrue(corrected.contains("title: String (Required)")); - assertEquals(corrected, WebPubSubChatCustomization.correctLifecycleDocumentation(corrected)); - assertEquals(withoutComments(source), withoutComments(corrected)); - } - - @ParameterizedTest - @ValueSource( - strings = { - "updateMessage", - "updateTopic", - "createOrReplaceTopic", - "createOrReplaceRole", - "createOrReplaceRoom", - "createOrReplaceRoomMember", - "createOrReplaceUser" }) - public void repairsAllWriteOperations(String operation) { - String fields; - String readOnly; - switch (operation) { - case "updateMessage": - fields = "createdBy: String (Optional, Required on create)\n" - + " * content (Optional, Required on create): {\n" - + " * text: String (Optional)\n * }"; - readOnly = "id,createdAt,etag"; - break; - - case "updateTopic": - case "createOrReplaceTopic": - fields = "title: String (Optional, Required on create)\n" - + " * state: String(Normal/Archived/SoftDeleted) (Optional, Required on create)"; - readOnly = "id,createdAt,createdBy,conversationId,etag"; - break; - - case "createOrReplaceRole": - fields = "permissions (Required): []"; - readOnly = "name,etag"; - break; - - case "createOrReplaceRoom": - fields = "title: String (Required)"; - readOnly = "id,defaultConversation,etag"; - break; - - case "createOrReplaceRoomMember": - fields = "roleName: String (Required)"; - readOnly = "userId,etag"; - break; - - case "createOrReplaceUser": - fields = "nickname: String (Required)\n * kind: String(Human) (Required)"; - readOnly = "id,etag"; - break; - - default: - throw new IllegalArgumentException(operation); - } - String schema = " * " + fields + "\n"; - for (String field : readOnly.split(",")) { - schema += " * " + field + ": String (Required)\n"; - } - for (String suffix : Arrays.asList("WithResponse", "WithResponseAsync")) { - String source = "class Example {\n/**\n * " + REQUEST + "\n" + schema + " * " + RESPONSE + "\n" + schema - + " * @param resource The resource.\n */\nvoid " + operation + suffix + "(Object resource) {}\n}"; - String corrected = WebPubSubChatCustomization.correctLifecycleDocumentation(source); - String request = corrected.substring(corrected.indexOf(REQUEST), corrected.indexOf(RESPONSE)); - String response = corrected.substring(corrected.indexOf(RESPONSE)); - for (String field : readOnly.split(",")) { - assertFalse(request.contains(" * " + field + ":"), operation + ": " + field); - assertTrue(response.contains(" * " + field + ":"), operation + ": " + field); - } - assertFalse(corrected.contains("Optional, Required on create"), operation); - if (operation.equals("updateMessage")) { - assertTrue(request.contains("content (Optional)")); - assertTrue(response.contains("content (Required)")); - assertTrue(response.contains("text: String (Optional)")); - } else if (operation.endsWith("Topic")) { - assertTrue(request - .contains("title: String (" + (operation.startsWith("update") ? "Optional" : "Required") + ")")); - assertTrue(request.contains("state: String(Normal/Archived/SoftDeleted) (Optional)")); - assertTrue(response.contains("title: String (Required)")); - assertTrue(response.contains("state: String(Normal/Archived/SoftDeleted) (Required)")); - } else { - assertTrue(request.contains(fields)); - } - assertEquals(corrected, WebPubSubChatCustomization.correctLifecycleDocumentation(corrected), operation); - assertEquals(withoutComments(source), withoutComments(corrected), operation); - } - } - - @Test - public void stateSetterPreservesHandwrittenDocumentation() throws IOException { - MethodDeclaration setter = StaticJavaParser.parse(SOURCE.resolve("models/ChatTopic.java")) - .findAll(MethodDeclaration.class) - .stream() - .filter(method -> method.getNameAsString().equals("setState")) - .findFirst() - .get(); - assertFalse(setter.getAnnotationByName("Generated").isPresent()); - String doc = setter.getJavadocComment().get().getContent().replaceAll("\\s*\\R\\s*\\*\\s*", " "); - assertTrue(doc.contains("When creating a topic, omit this property")); - assertTrue(doc.contains("{@link ChatTopicState#NORMAL}")); - assertTrue(doc.contains("Other states are only valid when updating an existing topic.")); - assertFalse(doc.contains("Required when create")); - } - - @Test - public void topicCreationDocumentsAllowedInitialState() throws IOException { - for (String file : Arrays.asList("WebPubSubChatServiceClient.java", "WebPubSubChatServiceAsyncClient.java", - "implementation/WebPubSubChatServiceClientImpl.java")) { - for (MethodDeclaration method : StaticJavaParser.parse(SOURCE.resolve(file)) - .findAll(MethodDeclaration.class)) { - if (method.getNameAsString().startsWith("createOrReplaceTopic") - && method.getJavadocComment().isPresent()) { - String doc = method.getJavadocComment().get().getContent().replaceAll("\\s*\\R\\s*\\*\\s*", " "); - assertTrue(doc.contains("When creating a topic, omit state or set it to Normal."), file); - assertTrue(doc.contains("Other states are only valid when updating an existing topic."), file); - } - } - } - } - - private static String withoutComments(String source) { - com.github.javaparser.ast.CompilationUnit ast = StaticJavaParser.parse(source); - ast.getAllContainedComments().forEach(comment -> comment.remove()); - return ast.toString(); - } -} diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/src/test/java/WebPubSubChatMessageContentCustomizationTests.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/src/test/java/WebPubSubChatMessageContentCustomizationTests.java deleted file mode 100644 index c3ffb42aa3dce..0000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/src/test/java/WebPubSubChatMessageContentCustomizationTests.java +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import com.github.javaparser.StaticJavaParser; -import com.github.javaparser.ast.CompilationUnit; -import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; -import org.junit.jupiter.api.Test; - -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Paths; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class WebPubSubChatMessageContentCustomizationTests { - @Test - public void removesRegeneratedMutableMembersAndIsIdempotent() throws IOException { - CompilationUnit ast = readModel(); - ClassOrInterfaceDeclaration original = ast.getClassByName("MessageContent").get(); - original.addMember(StaticJavaParser.parseBodyDeclaration( - "private final java.util.Set updatedProperties = new java.util.HashSet<>();")); - original.addMember( - StaticJavaParser.parseBodyDeclaration("public MessageContent setText(String text) { return this; }")); - original.addMember( - StaticJavaParser.parseBodyDeclaration("public MessageContent setBinary(byte[] binary) { return this; }")); - original.addMember(StaticJavaParser - .parseBodyDeclaration("private JsonWriter toJsonMergePatch(JsonWriter writer) { return writer; }")); - - WebPubSubChatCustomization.customizeMessageContent(ast); - ClassOrInterfaceDeclaration model = ast.getClassByName("MessageContent").get(); - assertEquals(1, model.getConstructors().size()); - assertTrue(model.getConstructors().get(0).isPrivate()); - assertTrue(model.getMethodsByName("setText").isEmpty()); - assertTrue(model.getMethodsByName("setBinary").isEmpty()); - assertTrue(model.getMethodsByName("fromText").get(0).isStatic()); - assertTrue(model.getMethodsByName("fromBinary").get(0).isStatic()); - assertTrue(model.getFieldByName("text").get().isFinal()); - assertTrue(model.getFieldByName("binary").get().isFinal()); - assertFalse(model.getFieldByName("updatedProperties").isPresent()); - assertTrue(model.getAnnotationByName("Immutable").isPresent()); - - String customized = ast.toString(); - WebPubSubChatCustomization.customizeMessageContent(ast); - assertEquals(customized, ast.toString()); - } - - @Test - public void checkedInModelIncludesCustomization() throws IOException { - CompilationUnit expected = readModel(); - ClassOrInterfaceDeclaration model = expected.getClassByName("MessageContent").get(); - for (String name : new String[] { "toJson", "fromJson", "fromText", "fromBinary" }) { - assertFalse(model.getMethodsByName(name).get(0).getAnnotationByName("Generated").isPresent()); - } - for (String name : new String[] { "text", "binary" }) { - assertFalse(model.getFieldByName(name).get().getAnnotationByName("Generated").isPresent()); - } - CompilationUnit actual = expected.clone(); - WebPubSubChatCustomization.customizeMessageContent(actual); - assertEquals(expected.toString(), actual.toString()); - } - - private static CompilationUnit readModel() throws IOException { - String source = new String(Files.readAllBytes(Paths.get("..", "src", "main", "java", "com", "azure", - "messaging", "webpubsub", "chat", "models", "MessageContent.java")), StandardCharsets.UTF_8); - return StaticJavaParser.parse(source); - } -} diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceAsyncClient.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceAsyncClient.java index 189f0e64f165e..2a7cc5eac5a8b 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceAsyncClient.java +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceAsyncClient.java @@ -1746,9 +1746,6 @@ public PagedFlux listTopics(String roomId, RequestOptions requestOpt /** * Create or replace a topic. * - *

When creating a topic, omit state or set it to Normal. Other states are only valid when updating an existing - * topic.

- * * Create or replace a topic with a client-specified ID. *

Header Parameters

* @@ -2173,9 +2170,6 @@ public PagedFlux listTopics(String roomId) { /** * Create or replace a topic. * - *

When creating a topic, omit state or set it to Normal. Other states are only valid when updating an existing - * topic.

- * * Create or replace a topic with a client-specified ID. * * @param roomId Room identifier. @@ -2212,9 +2206,6 @@ public Mono createOrReplaceTopic(String roomId, String topicId, ChatT /** * Create or replace a topic. * - *

When creating a topic, omit state or set it to Normal. Other states are only valid when updating an existing - * topic.

- * * Create or replace a topic with a client-specified ID. * * @param roomId Room identifier. diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceClient.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceClient.java index 1f93cb6fda8c2..a1ef533d1c50b 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceClient.java +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceClient.java @@ -1602,9 +1602,6 @@ public PagedIterable listTopics(String roomId, RequestOptions reques /** * Create or replace a topic. * - *

When creating a topic, omit state or set it to Normal. Other states are only valid when updating an existing - * topic.

- * * Create or replace a topic with a client-specified ID. *

Header Parameters

*
@@ -1954,9 +1951,6 @@ public PagedIterable listTopics(String roomId) { /** * Create or replace a topic. * - *

When creating a topic, omit state or set it to Normal. Other states are only valid when updating an existing - * topic.

- * * Create or replace a topic with a client-specified ID. * * @param roomId Room identifier. @@ -1993,9 +1987,6 @@ public ChatTopic createOrReplaceTopic(String roomId, String topicId, ChatTopic t /** * Create or replace a topic. * - *

When creating a topic, omit state or set it to Normal. Other states are only valid when updating an existing - * topic.

- * * Create or replace a topic with a client-specified ID. * * @param roomId Room identifier. diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/implementation/WebPubSubChatServiceClientImpl.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/implementation/WebPubSubChatServiceClientImpl.java index bc425f8d355c1..c3ee518074281 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/implementation/WebPubSubChatServiceClientImpl.java +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/implementation/WebPubSubChatServiceClientImpl.java @@ -2503,9 +2503,6 @@ public PagedIterable listTopics(String roomId, RequestOptions reques /** * Create or replace a topic. * - *

When creating a topic, omit state or set it to Normal. Other states are only valid when updating an existing - * topic.

- * * Create or replace a topic with a client-specified ID. *

Header Parameters

*
@@ -2574,9 +2571,6 @@ public Mono> createOrReplaceTopicWithResponseAsync(String r /** * Create or replace a topic. * - *

When creating a topic, omit state or set it to Normal. Other states are only valid when updating an existing - * topic.

- * * Create or replace a topic with a client-specified ID. *

Header Parameters

*
diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/ChatTopic.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/ChatTopic.java index 00edf74c378f2..65801f040c4df 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/ChatTopic.java +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/ChatTopic.java @@ -167,8 +167,7 @@ public ChatTopicState getState() { /** * Set the state property: Current lifecycle state of the topic. - *

When creating a topic, omit this property or set it to {@link ChatTopicState#NORMAL}. Other states are only - * valid when updating an existing topic.

+ *

For a new topic, omit this property or set it to {@link ChatTopicState#NORMAL}.

* * @param state the state value to set. * @return the ChatTopic object itself. From 3f3f540545aa3ba4a54fb15762a09249311e3595 Mon Sep 17 00:00:00 2001 From: Zitong Yang Date: Thu, 29 Oct 2026 02:04:55 -0700 Subject: [PATCH 14/18] Pin Chat SDK to spec validation fixes Regeneration preserves the existing Java API and implementation and refreshes the cross-language version metadata. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .../META-INF/azure-messaging-webpubsub-chat_metadata.json | 2 +- sdk/webpubsub/azure-messaging-webpubsub-chat/tsp-location.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/resources/META-INF/azure-messaging-webpubsub-chat_metadata.json b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/resources/META-INF/azure-messaging-webpubsub-chat_metadata.json index 26bdd302713db..7db8ec1f39e59 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/resources/META-INF/azure-messaging-webpubsub-chat_metadata.json +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/resources/META-INF/azure-messaging-webpubsub-chat_metadata.json @@ -1 +1 @@ -{"flavor":"azure","apiVersions":{"WebPubSubChat":"2026-08-01-preview"},"crossLanguagePackageId":"WebPubSubChat","crossLanguageVersion":"32d235898555","crossLanguageDefinitions":{"com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient":"Customizations.WebPubSubChatServiceClient","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceRole":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceRoleWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceRoom":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceRoomMember":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoomMember","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceRoomMemberWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoomMember","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceRoomWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceTopic":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceTopicWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceUser":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceUserWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteMessage":"WebPubSubChat.WebPubSubChatServiceClient.deleteMessage","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteMessageWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteMessage","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteRole":"WebPubSubChat.WebPubSubChatServiceClient.deleteRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteRoleWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteRoom":"WebPubSubChat.WebPubSubChatServiceClient.deleteRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteRoomMember":"WebPubSubChat.WebPubSubChatServiceClient.deleteRoomMember","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteRoomMemberWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteRoomMember","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteRoomWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteTopic":"WebPubSubChat.WebPubSubChatServiceClient.deleteTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteTopicWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteUser":"WebPubSubChat.WebPubSubChatServiceClient.deleteUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteUserWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.generateClientToken":"Customizations.WebPubSubChatServiceClient.generateClientToken","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.generateClientTokenWithResponse":"Customizations.WebPubSubChatServiceClient.generateClientToken","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getConversation":"WebPubSubChat.WebPubSubChatServiceClient.getConversation","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getConversationWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getConversation","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getRole":"WebPubSubChat.WebPubSubChatServiceClient.getRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getRoleWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getRoom":"WebPubSubChat.WebPubSubChatServiceClient.getRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getRoomWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getTopic":"WebPubSubChat.WebPubSubChatServiceClient.getTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getTopicWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getUser":"WebPubSubChat.WebPubSubChatServiceClient.getUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getUserWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.listMessages":"WebPubSubChat.WebPubSubChatServiceClient.listMessages","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.listRoles":"WebPubSubChat.WebPubSubChatServiceClient.listRoles","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.listRoomMembers":"WebPubSubChat.WebPubSubChatServiceClient.listRoomMembers","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.listRooms":"WebPubSubChat.WebPubSubChatServiceClient.listRooms","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.listRoomsForUser":"WebPubSubChat.WebPubSubChatServiceClient.listRoomsForUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.listTopics":"WebPubSubChat.WebPubSubChatServiceClient.listTopics","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.listUsers":"WebPubSubChat.WebPubSubChatServiceClient.listUsers","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.updateMessage":"WebPubSubChat.WebPubSubChatServiceClient.updateMessage","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.updateMessageWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.updateMessage","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.updateTopic":"WebPubSubChat.WebPubSubChatServiceClient.updateTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.updateTopicWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.updateTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient":"Customizations.WebPubSubChatServiceClient","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceRole":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceRoleWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceRoom":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceRoomMember":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoomMember","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceRoomMemberWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoomMember","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceRoomWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceTopic":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceTopicWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceUser":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceUserWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteMessage":"WebPubSubChat.WebPubSubChatServiceClient.deleteMessage","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteMessageWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteMessage","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteRole":"WebPubSubChat.WebPubSubChatServiceClient.deleteRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteRoleWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteRoom":"WebPubSubChat.WebPubSubChatServiceClient.deleteRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteRoomMember":"WebPubSubChat.WebPubSubChatServiceClient.deleteRoomMember","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteRoomMemberWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteRoomMember","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteRoomWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteTopic":"WebPubSubChat.WebPubSubChatServiceClient.deleteTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteTopicWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteUser":"WebPubSubChat.WebPubSubChatServiceClient.deleteUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteUserWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.generateClientToken":"Customizations.WebPubSubChatServiceClient.generateClientToken","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.generateClientTokenWithResponse":"Customizations.WebPubSubChatServiceClient.generateClientToken","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getConversation":"WebPubSubChat.WebPubSubChatServiceClient.getConversation","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getConversationWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getConversation","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getRole":"WebPubSubChat.WebPubSubChatServiceClient.getRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getRoleWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getRoom":"WebPubSubChat.WebPubSubChatServiceClient.getRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getRoomWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getTopic":"WebPubSubChat.WebPubSubChatServiceClient.getTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getTopicWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getUser":"WebPubSubChat.WebPubSubChatServiceClient.getUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getUserWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.listMessages":"WebPubSubChat.WebPubSubChatServiceClient.listMessages","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.listRoles":"WebPubSubChat.WebPubSubChatServiceClient.listRoles","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.listRoomMembers":"WebPubSubChat.WebPubSubChatServiceClient.listRoomMembers","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.listRooms":"WebPubSubChat.WebPubSubChatServiceClient.listRooms","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.listRoomsForUser":"WebPubSubChat.WebPubSubChatServiceClient.listRoomsForUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.listTopics":"WebPubSubChat.WebPubSubChatServiceClient.listTopics","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.listUsers":"WebPubSubChat.WebPubSubChatServiceClient.listUsers","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.updateMessage":"WebPubSubChat.WebPubSubChatServiceClient.updateMessage","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.updateMessageWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.updateMessage","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.updateTopic":"WebPubSubChat.WebPubSubChatServiceClient.updateTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.updateTopicWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.updateTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClientBuilder":"Customizations.WebPubSubChatServiceClient","com.azure.messaging.webpubsub.chat.implementation.models.GenerateClientTokenResponse":"Customizations.GenerateClientTokenResponse","com.azure.messaging.webpubsub.chat.models.ChatConversation":"WebPubSubChat.ChatConversation","com.azure.messaging.webpubsub.chat.models.ChatMessage":"WebPubSubChat.ChatMessage","com.azure.messaging.webpubsub.chat.models.ChatPermission":"WebPubSubChat.ChatPermission","com.azure.messaging.webpubsub.chat.models.ChatRole":"WebPubSubChat.ChatRole","com.azure.messaging.webpubsub.chat.models.ChatRoom":"WebPubSubChat.ChatRoom","com.azure.messaging.webpubsub.chat.models.ChatRoomMember":"WebPubSubChat.ChatRoomMember","com.azure.messaging.webpubsub.chat.models.ChatTopic":"WebPubSubChat.ChatTopic","com.azure.messaging.webpubsub.chat.models.ChatTopicState":"WebPubSubChat.ChatTopicState","com.azure.messaging.webpubsub.chat.models.ChatUser":"WebPubSubChat.ChatUser","com.azure.messaging.webpubsub.chat.models.ChatUserKind":"WebPubSubChat.ChatUserKind","com.azure.messaging.webpubsub.chat.models.ChatUserRoom":"WebPubSubChat.ChatUserRoom","com.azure.messaging.webpubsub.chat.models.HumanChatUser":"WebPubSubChat.HumanChatUser","com.azure.messaging.webpubsub.chat.models.MessageContent":"WebPubSubChat.MessageContent"},"generatedFiles":["src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceAsyncClient.java","src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceClient.java","src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceClientBuilder.java","src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceVersion.java","src/main/java/com/azure/messaging/webpubsub/chat/implementation/JsonMergePatchHelper.java","src/main/java/com/azure/messaging/webpubsub/chat/implementation/WebPubSubChatServiceClientImpl.java","src/main/java/com/azure/messaging/webpubsub/chat/implementation/models/GenerateClientTokenResponse.java","src/main/java/com/azure/messaging/webpubsub/chat/implementation/models/package-info.java","src/main/java/com/azure/messaging/webpubsub/chat/implementation/package-info.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatConversation.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatMessage.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatPermission.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatRole.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatRoom.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatRoomMember.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatTopic.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatTopicState.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatUser.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatUserKind.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatUserRoom.java","src/main/java/com/azure/messaging/webpubsub/chat/models/HumanChatUser.java","src/main/java/com/azure/messaging/webpubsub/chat/models/MessageContent.java","src/main/java/com/azure/messaging/webpubsub/chat/models/package-info.java","src/main/java/com/azure/messaging/webpubsub/chat/package-info.java","src/main/java/module-info.java"]} \ No newline at end of file +{"flavor":"azure","apiVersions":{"WebPubSubChat":"2026-08-01-preview"},"crossLanguagePackageId":"WebPubSubChat","crossLanguageVersion":"92ff2ee181d9","crossLanguageDefinitions":{"com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient":"Customizations.WebPubSubChatServiceClient","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceRole":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceRoleWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceRoom":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceRoomMember":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoomMember","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceRoomMemberWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoomMember","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceRoomWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceTopic":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceTopicWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceUser":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceUserWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteMessage":"WebPubSubChat.WebPubSubChatServiceClient.deleteMessage","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteMessageWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteMessage","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteRole":"WebPubSubChat.WebPubSubChatServiceClient.deleteRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteRoleWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteRoom":"WebPubSubChat.WebPubSubChatServiceClient.deleteRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteRoomMember":"WebPubSubChat.WebPubSubChatServiceClient.deleteRoomMember","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteRoomMemberWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteRoomMember","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteRoomWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteTopic":"WebPubSubChat.WebPubSubChatServiceClient.deleteTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteTopicWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteUser":"WebPubSubChat.WebPubSubChatServiceClient.deleteUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteUserWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.generateClientToken":"Customizations.WebPubSubChatServiceClient.generateClientToken","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.generateClientTokenWithResponse":"Customizations.WebPubSubChatServiceClient.generateClientToken","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getConversation":"WebPubSubChat.WebPubSubChatServiceClient.getConversation","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getConversationWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getConversation","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getRole":"WebPubSubChat.WebPubSubChatServiceClient.getRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getRoleWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getRoom":"WebPubSubChat.WebPubSubChatServiceClient.getRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getRoomWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getTopic":"WebPubSubChat.WebPubSubChatServiceClient.getTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getTopicWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getUser":"WebPubSubChat.WebPubSubChatServiceClient.getUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getUserWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.listMessages":"WebPubSubChat.WebPubSubChatServiceClient.listMessages","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.listRoles":"WebPubSubChat.WebPubSubChatServiceClient.listRoles","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.listRoomMembers":"WebPubSubChat.WebPubSubChatServiceClient.listRoomMembers","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.listRooms":"WebPubSubChat.WebPubSubChatServiceClient.listRooms","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.listRoomsForUser":"WebPubSubChat.WebPubSubChatServiceClient.listRoomsForUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.listTopics":"WebPubSubChat.WebPubSubChatServiceClient.listTopics","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.listUsers":"WebPubSubChat.WebPubSubChatServiceClient.listUsers","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.updateMessage":"WebPubSubChat.WebPubSubChatServiceClient.updateMessage","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.updateMessageWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.updateMessage","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.updateTopic":"WebPubSubChat.WebPubSubChatServiceClient.updateTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.updateTopicWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.updateTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient":"Customizations.WebPubSubChatServiceClient","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceRole":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceRoleWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceRoom":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceRoomMember":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoomMember","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceRoomMemberWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoomMember","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceRoomWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceTopic":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceTopicWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceUser":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceUserWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteMessage":"WebPubSubChat.WebPubSubChatServiceClient.deleteMessage","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteMessageWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteMessage","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteRole":"WebPubSubChat.WebPubSubChatServiceClient.deleteRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteRoleWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteRoom":"WebPubSubChat.WebPubSubChatServiceClient.deleteRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteRoomMember":"WebPubSubChat.WebPubSubChatServiceClient.deleteRoomMember","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteRoomMemberWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteRoomMember","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteRoomWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteTopic":"WebPubSubChat.WebPubSubChatServiceClient.deleteTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteTopicWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteUser":"WebPubSubChat.WebPubSubChatServiceClient.deleteUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteUserWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.generateClientToken":"Customizations.WebPubSubChatServiceClient.generateClientToken","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.generateClientTokenWithResponse":"Customizations.WebPubSubChatServiceClient.generateClientToken","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getConversation":"WebPubSubChat.WebPubSubChatServiceClient.getConversation","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getConversationWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getConversation","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getRole":"WebPubSubChat.WebPubSubChatServiceClient.getRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getRoleWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getRoom":"WebPubSubChat.WebPubSubChatServiceClient.getRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getRoomWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getTopic":"WebPubSubChat.WebPubSubChatServiceClient.getTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getTopicWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getUser":"WebPubSubChat.WebPubSubChatServiceClient.getUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getUserWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.listMessages":"WebPubSubChat.WebPubSubChatServiceClient.listMessages","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.listRoles":"WebPubSubChat.WebPubSubChatServiceClient.listRoles","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.listRoomMembers":"WebPubSubChat.WebPubSubChatServiceClient.listRoomMembers","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.listRooms":"WebPubSubChat.WebPubSubChatServiceClient.listRooms","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.listRoomsForUser":"WebPubSubChat.WebPubSubChatServiceClient.listRoomsForUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.listTopics":"WebPubSubChat.WebPubSubChatServiceClient.listTopics","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.listUsers":"WebPubSubChat.WebPubSubChatServiceClient.listUsers","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.updateMessage":"WebPubSubChat.WebPubSubChatServiceClient.updateMessage","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.updateMessageWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.updateMessage","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.updateTopic":"WebPubSubChat.WebPubSubChatServiceClient.updateTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.updateTopicWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.updateTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClientBuilder":"Customizations.WebPubSubChatServiceClient","com.azure.messaging.webpubsub.chat.implementation.models.GenerateClientTokenResponse":"Customizations.GenerateClientTokenResponse","com.azure.messaging.webpubsub.chat.models.ChatConversation":"WebPubSubChat.ChatConversation","com.azure.messaging.webpubsub.chat.models.ChatMessage":"WebPubSubChat.ChatMessage","com.azure.messaging.webpubsub.chat.models.ChatPermission":"WebPubSubChat.ChatPermission","com.azure.messaging.webpubsub.chat.models.ChatRole":"WebPubSubChat.ChatRole","com.azure.messaging.webpubsub.chat.models.ChatRoom":"WebPubSubChat.ChatRoom","com.azure.messaging.webpubsub.chat.models.ChatRoomMember":"WebPubSubChat.ChatRoomMember","com.azure.messaging.webpubsub.chat.models.ChatTopic":"WebPubSubChat.ChatTopic","com.azure.messaging.webpubsub.chat.models.ChatTopicState":"WebPubSubChat.ChatTopicState","com.azure.messaging.webpubsub.chat.models.ChatUser":"WebPubSubChat.ChatUser","com.azure.messaging.webpubsub.chat.models.ChatUserKind":"WebPubSubChat.ChatUserKind","com.azure.messaging.webpubsub.chat.models.ChatUserRoom":"WebPubSubChat.ChatUserRoom","com.azure.messaging.webpubsub.chat.models.HumanChatUser":"WebPubSubChat.HumanChatUser","com.azure.messaging.webpubsub.chat.models.MessageContent":"WebPubSubChat.MessageContent"},"generatedFiles":["src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceAsyncClient.java","src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceClient.java","src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceClientBuilder.java","src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceVersion.java","src/main/java/com/azure/messaging/webpubsub/chat/implementation/JsonMergePatchHelper.java","src/main/java/com/azure/messaging/webpubsub/chat/implementation/WebPubSubChatServiceClientImpl.java","src/main/java/com/azure/messaging/webpubsub/chat/implementation/models/GenerateClientTokenResponse.java","src/main/java/com/azure/messaging/webpubsub/chat/implementation/models/package-info.java","src/main/java/com/azure/messaging/webpubsub/chat/implementation/package-info.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatConversation.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatMessage.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatPermission.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatRole.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatRoom.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatRoomMember.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatTopic.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatTopicState.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatUser.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatUserKind.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatUserRoom.java","src/main/java/com/azure/messaging/webpubsub/chat/models/HumanChatUser.java","src/main/java/com/azure/messaging/webpubsub/chat/models/MessageContent.java","src/main/java/com/azure/messaging/webpubsub/chat/models/package-info.java","src/main/java/com/azure/messaging/webpubsub/chat/package-info.java","src/main/java/module-info.java"]} \ No newline at end of file diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/tsp-location.yaml b/sdk/webpubsub/azure-messaging-webpubsub-chat/tsp-location.yaml index 8e0ea00e7c45d..dbfdb1f549527 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/tsp-location.yaml +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/tsp-location.yaml @@ -1,4 +1,4 @@ directory: specification/webpubsub/data-plane/WebPubSubChat -commit: 03fa779a6c4ee641e12f63b73c8fdc5e35120156 +commit: cac305c7810afd20b8cfa009852d4fb0975c528a repo: Azure/azure-rest-api-specs additionalDirectories: From 2d9a211dade60e4131cab94a63a8db18662985f9 Mon Sep 17 00:00:00 2001 From: Zitong Yang Date: Thu, 29 Oct 2026 22:04:59 +1100 Subject: [PATCH 15/18] Simplify Chat SDK documentation and sync TypeSpec description Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- sdk/webpubsub/azure-messaging-webpubsub-chat/README.md | 5 +++-- .../src/main/java/WebPubSubChatCustomization.java | 9 +++++++-- .../webpubsub/chat/WebPubSubChatServiceAsyncClient.java | 9 ++++++--- .../webpubsub/chat/WebPubSubChatServiceClient.java | 9 ++++++--- .../implementation/WebPubSubChatServiceClientImpl.java | 8 ++++---- .../webpubsub/chat/models/ClientAccessTokenOptions.java | 5 +---- .../messaging/webpubsub/chat/models/MessageContent.java | 2 -- .../azure-messaging-webpubsub-chat_metadata.json | 2 +- .../azure-messaging-webpubsub-chat/tsp-location.yaml | 2 +- 9 files changed, 29 insertions(+), 22 deletions(-) diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/README.md b/sdk/webpubsub/azure-messaging-webpubsub-chat/README.md index d55d7c60c1253..6f645427ae2dc 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/README.md +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/README.md @@ -235,8 +235,9 @@ String conversationId = topic.getConversationId(); ``` When creating a topic, leave `state` unset (as above) or set it to -`ChatTopicState.NORMAL`. Use `updateTopic` to change selected properties of an existing -topic instead of replacing it with `createOrReplaceTopic`. +`ChatTopicState.NORMAL`. For `createOrReplaceTopic`, other states are only valid when +replacing an existing topic. Use `updateTopic` to change selected properties of an +existing topic. Use the returned conversation ID when a Chat WebSocket client sends messages to the topic. This server-side library manages resources and persisted messages; diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/src/main/java/WebPubSubChatCustomization.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/src/main/java/WebPubSubChatCustomization.java index 4b318b1e32c96..002a285cf4620 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/src/main/java/WebPubSubChatCustomization.java +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/src/main/java/WebPubSubChatCustomization.java @@ -99,6 +99,13 @@ static String correctLifecycleDocumentation(String source) { } corrected = corrected.substring(0, requestStart) + request + corrected.substring(responseStart); } + if (method.getNameAsString().startsWith("createOrReplaceTopic") + && !corrected.contains("When creating a topic, omit state")) { + corrected = corrected.replace("Create or replace a topic.", + "Create or replace a topic.\n *\n" + + " *

When creating a topic, omit state. " + + "Other states are only valid when replacing an existing topic.

"); + } if (!original.equals(corrected)) { source = source.replace(original, corrected); } @@ -122,8 +129,6 @@ static void customizeMessageContent(CompilationUnit ast) { } model.setJavadocComment("Message content containing exactly one of text or binary data.\n" + "Use {@link #fromText(String)} or {@link #fromBinary(byte[])} to create content.\n" - + "Text and binary are independent content types, not alternate encodings of the same value.\n" - + "Binary data is base64 encoded on the wire. No conversion between text and binary is performed.\n" + "The getter for the unselected representation returns {@code null}."); model.getFieldByName("updatedProperties").ifPresent(field -> field.remove()); model.getMethodsByName("setText").forEach(method -> method.remove()); diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceAsyncClient.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceAsyncClient.java index 2a7cc5eac5a8b..2a8619d3ff320 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceAsyncClient.java +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceAsyncClient.java @@ -88,7 +88,6 @@ public Mono> getConversationWithResponse(String conversatio /** * Query messages in a conversation from latest to earliest. * - * Query messages in a conversation from latest to earliest. * Message IDs are used as pagination cursors. Follow the response nextLink, * which contains the message ID cursor, to retrieve the next page. *

Query Parameters

@@ -773,7 +772,6 @@ public Mono getConversation(String conversationId) { /** * Query messages in a conversation from latest to earliest. * - * Query messages in a conversation from latest to earliest. * Message IDs are used as pagination cursors. Follow the response nextLink, * which contains the message ID cursor, to retrieve the next page. * @@ -825,7 +823,6 @@ public PagedFlux listMessages(String conversationId, String latestM /** * Query messages in a conversation from latest to earliest. * - * Query messages in a conversation from latest to earliest. * Message IDs are used as pagination cursors. Follow the response nextLink, * which contains the message ID cursor, to retrieve the next page. * @@ -1746,6 +1743,8 @@ public PagedFlux listTopics(String roomId, RequestOptions requestOpt /** * Create or replace a topic. * + *

When creating a topic, omit state. Other states are only valid when replacing an existing topic.

+ * * Create or replace a topic with a client-specified ID. *

Header Parameters

*
@@ -2170,6 +2169,8 @@ public PagedFlux listTopics(String roomId) { /** * Create or replace a topic. * + *

When creating a topic, omit state. Other states are only valid when replacing an existing topic.

+ * * Create or replace a topic with a client-specified ID. * * @param roomId Room identifier. @@ -2206,6 +2207,8 @@ public Mono createOrReplaceTopic(String roomId, String topicId, ChatT /** * Create or replace a topic. * + *

When creating a topic, omit state. Other states are only valid when replacing an existing topic.

+ * * Create or replace a topic with a client-specified ID. * * @param roomId Room identifier. diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceClient.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceClient.java index a1ef533d1c50b..9c4a8c853441f 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceClient.java +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceClient.java @@ -81,7 +81,6 @@ public Response getConversationWithResponse(String conversationId, R /** * Query messages in a conversation from latest to earliest. * - * Query messages in a conversation from latest to earliest. * Message IDs are used as pagination cursors. Follow the response nextLink, * which contains the message ID cursor, to retrieve the next page. *

Query Parameters

@@ -762,7 +761,6 @@ public ChatConversation getConversation(String conversationId) { /** * Query messages in a conversation from latest to earliest. * - * Query messages in a conversation from latest to earliest. * Message IDs are used as pagination cursors. Follow the response nextLink, * which contains the message ID cursor, to retrieve the next page. * @@ -796,7 +794,6 @@ public PagedIterable listMessages(String conversationId, String lat /** * Query messages in a conversation from latest to earliest. * - * Query messages in a conversation from latest to earliest. * Message IDs are used as pagination cursors. Follow the response nextLink, * which contains the message ID cursor, to retrieve the next page. * @@ -1602,6 +1599,8 @@ public PagedIterable listTopics(String roomId, RequestOptions reques /** * Create or replace a topic. * + *

When creating a topic, omit state. Other states are only valid when replacing an existing topic.

+ * * Create or replace a topic with a client-specified ID. *

Header Parameters

*
@@ -1951,6 +1950,8 @@ public PagedIterable listTopics(String roomId) { /** * Create or replace a topic. * + *

When creating a topic, omit state. Other states are only valid when replacing an existing topic.

+ * * Create or replace a topic with a client-specified ID. * * @param roomId Room identifier. @@ -1987,6 +1988,8 @@ public ChatTopic createOrReplaceTopic(String roomId, String topicId, ChatTopic t /** * Create or replace a topic. * + *

When creating a topic, omit state. Other states are only valid when replacing an existing topic.

+ * * Create or replace a topic with a client-specified ID. * * @param roomId Room identifier. diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/implementation/WebPubSubChatServiceClientImpl.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/implementation/WebPubSubChatServiceClientImpl.java index c3ee518074281..f8e95cdacb283 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/implementation/WebPubSubChatServiceClientImpl.java +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/implementation/WebPubSubChatServiceClientImpl.java @@ -962,7 +962,6 @@ public Response getConversationWithResponse(String conversationId, R /** * Query messages in a conversation from latest to earliest. * - * Query messages in a conversation from latest to earliest. * Message IDs are used as pagination cursors. Follow the response nextLink, * which contains the message ID cursor, to retrieve the next page. *

Query Parameters

@@ -1015,7 +1014,6 @@ private Mono> listMessagesSinglePageAsync(String conve /** * Query messages in a conversation from latest to earliest. * - * Query messages in a conversation from latest to earliest. * Message IDs are used as pagination cursors. Follow the response nextLink, * which contains the message ID cursor, to retrieve the next page. *

Query Parameters

@@ -1085,7 +1083,6 @@ public PagedFlux listMessagesAsync(String conversationId, RequestOpt /** * Query messages in a conversation from latest to earliest. * - * Query messages in a conversation from latest to earliest. * Message IDs are used as pagination cursors. Follow the response nextLink, * which contains the message ID cursor, to retrieve the next page. *

Query Parameters

@@ -1135,7 +1132,6 @@ private PagedResponse listMessagesSinglePage(String conversationId, /** * Query messages in a conversation from latest to earliest. * - * Query messages in a conversation from latest to earliest. * Message IDs are used as pagination cursors. Follow the response nextLink, * which contains the message ID cursor, to retrieve the next page. *

Query Parameters

@@ -2503,6 +2499,8 @@ public PagedIterable listTopics(String roomId, RequestOptions reques /** * Create or replace a topic. * + *

When creating a topic, omit state. Other states are only valid when replacing an existing topic.

+ * * Create or replace a topic with a client-specified ID. *

Header Parameters

*
@@ -2571,6 +2569,8 @@ public Mono> createOrReplaceTopicWithResponseAsync(String r /** * Create or replace a topic. * + *

When creating a topic, omit state. Other states are only valid when replacing an existing topic.

+ * * Create or replace a topic with a client-specified ID. *

Header Parameters

*
diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/ClientAccessTokenOptions.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/ClientAccessTokenOptions.java index 43555ae692f68..9cf14d376f39a 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/ClientAccessTokenOptions.java +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/ClientAccessTokenOptions.java @@ -6,10 +6,7 @@ import java.time.Duration; /** - * Options for creating a client access token used to connect to Azure Web PubSub Chat. - * The token can identify a user and has a configurable lifetime, which defaults to one hour. - * Clients authenticated with an access key sign the token locally; clients authenticated with - * Microsoft Entra ID request the token from the service. + * Options for the {@code getClientAccessToken} operation. */ public final class ClientAccessTokenOptions { private Duration expiresAfter = Duration.ofHours(1); diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/MessageContent.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/MessageContent.java index f746d69943cc1..d71498aaa3da3 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/MessageContent.java +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/MessageContent.java @@ -18,8 +18,6 @@ /** * Message content containing exactly one of text or binary data. * Use {@link #fromText(String)} or {@link #fromBinary(byte[])} to create content. - * Text and binary are independent content types, not alternate encodings of the same value. - * Binary data is base64 encoded on the wire. No conversion between text and binary is performed. * The getter for the unselected representation returns {@code null}. */ @Immutable diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/resources/META-INF/azure-messaging-webpubsub-chat_metadata.json b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/resources/META-INF/azure-messaging-webpubsub-chat_metadata.json index 7db8ec1f39e59..3e918ec34a635 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/resources/META-INF/azure-messaging-webpubsub-chat_metadata.json +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/resources/META-INF/azure-messaging-webpubsub-chat_metadata.json @@ -1 +1 @@ -{"flavor":"azure","apiVersions":{"WebPubSubChat":"2026-08-01-preview"},"crossLanguagePackageId":"WebPubSubChat","crossLanguageVersion":"92ff2ee181d9","crossLanguageDefinitions":{"com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient":"Customizations.WebPubSubChatServiceClient","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceRole":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceRoleWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceRoom":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceRoomMember":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoomMember","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceRoomMemberWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoomMember","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceRoomWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceTopic":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceTopicWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceUser":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceUserWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteMessage":"WebPubSubChat.WebPubSubChatServiceClient.deleteMessage","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteMessageWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteMessage","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteRole":"WebPubSubChat.WebPubSubChatServiceClient.deleteRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteRoleWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteRoom":"WebPubSubChat.WebPubSubChatServiceClient.deleteRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteRoomMember":"WebPubSubChat.WebPubSubChatServiceClient.deleteRoomMember","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteRoomMemberWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteRoomMember","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteRoomWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteTopic":"WebPubSubChat.WebPubSubChatServiceClient.deleteTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteTopicWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteUser":"WebPubSubChat.WebPubSubChatServiceClient.deleteUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteUserWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.generateClientToken":"Customizations.WebPubSubChatServiceClient.generateClientToken","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.generateClientTokenWithResponse":"Customizations.WebPubSubChatServiceClient.generateClientToken","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getConversation":"WebPubSubChat.WebPubSubChatServiceClient.getConversation","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getConversationWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getConversation","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getRole":"WebPubSubChat.WebPubSubChatServiceClient.getRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getRoleWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getRoom":"WebPubSubChat.WebPubSubChatServiceClient.getRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getRoomWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getTopic":"WebPubSubChat.WebPubSubChatServiceClient.getTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getTopicWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getUser":"WebPubSubChat.WebPubSubChatServiceClient.getUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getUserWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.listMessages":"WebPubSubChat.WebPubSubChatServiceClient.listMessages","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.listRoles":"WebPubSubChat.WebPubSubChatServiceClient.listRoles","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.listRoomMembers":"WebPubSubChat.WebPubSubChatServiceClient.listRoomMembers","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.listRooms":"WebPubSubChat.WebPubSubChatServiceClient.listRooms","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.listRoomsForUser":"WebPubSubChat.WebPubSubChatServiceClient.listRoomsForUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.listTopics":"WebPubSubChat.WebPubSubChatServiceClient.listTopics","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.listUsers":"WebPubSubChat.WebPubSubChatServiceClient.listUsers","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.updateMessage":"WebPubSubChat.WebPubSubChatServiceClient.updateMessage","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.updateMessageWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.updateMessage","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.updateTopic":"WebPubSubChat.WebPubSubChatServiceClient.updateTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.updateTopicWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.updateTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient":"Customizations.WebPubSubChatServiceClient","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceRole":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceRoleWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceRoom":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceRoomMember":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoomMember","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceRoomMemberWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoomMember","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceRoomWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceTopic":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceTopicWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceUser":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceUserWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteMessage":"WebPubSubChat.WebPubSubChatServiceClient.deleteMessage","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteMessageWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteMessage","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteRole":"WebPubSubChat.WebPubSubChatServiceClient.deleteRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteRoleWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteRoom":"WebPubSubChat.WebPubSubChatServiceClient.deleteRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteRoomMember":"WebPubSubChat.WebPubSubChatServiceClient.deleteRoomMember","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteRoomMemberWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteRoomMember","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteRoomWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteTopic":"WebPubSubChat.WebPubSubChatServiceClient.deleteTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteTopicWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteUser":"WebPubSubChat.WebPubSubChatServiceClient.deleteUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteUserWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.generateClientToken":"Customizations.WebPubSubChatServiceClient.generateClientToken","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.generateClientTokenWithResponse":"Customizations.WebPubSubChatServiceClient.generateClientToken","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getConversation":"WebPubSubChat.WebPubSubChatServiceClient.getConversation","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getConversationWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getConversation","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getRole":"WebPubSubChat.WebPubSubChatServiceClient.getRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getRoleWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getRoom":"WebPubSubChat.WebPubSubChatServiceClient.getRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getRoomWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getTopic":"WebPubSubChat.WebPubSubChatServiceClient.getTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getTopicWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getUser":"WebPubSubChat.WebPubSubChatServiceClient.getUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getUserWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.listMessages":"WebPubSubChat.WebPubSubChatServiceClient.listMessages","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.listRoles":"WebPubSubChat.WebPubSubChatServiceClient.listRoles","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.listRoomMembers":"WebPubSubChat.WebPubSubChatServiceClient.listRoomMembers","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.listRooms":"WebPubSubChat.WebPubSubChatServiceClient.listRooms","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.listRoomsForUser":"WebPubSubChat.WebPubSubChatServiceClient.listRoomsForUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.listTopics":"WebPubSubChat.WebPubSubChatServiceClient.listTopics","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.listUsers":"WebPubSubChat.WebPubSubChatServiceClient.listUsers","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.updateMessage":"WebPubSubChat.WebPubSubChatServiceClient.updateMessage","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.updateMessageWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.updateMessage","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.updateTopic":"WebPubSubChat.WebPubSubChatServiceClient.updateTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.updateTopicWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.updateTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClientBuilder":"Customizations.WebPubSubChatServiceClient","com.azure.messaging.webpubsub.chat.implementation.models.GenerateClientTokenResponse":"Customizations.GenerateClientTokenResponse","com.azure.messaging.webpubsub.chat.models.ChatConversation":"WebPubSubChat.ChatConversation","com.azure.messaging.webpubsub.chat.models.ChatMessage":"WebPubSubChat.ChatMessage","com.azure.messaging.webpubsub.chat.models.ChatPermission":"WebPubSubChat.ChatPermission","com.azure.messaging.webpubsub.chat.models.ChatRole":"WebPubSubChat.ChatRole","com.azure.messaging.webpubsub.chat.models.ChatRoom":"WebPubSubChat.ChatRoom","com.azure.messaging.webpubsub.chat.models.ChatRoomMember":"WebPubSubChat.ChatRoomMember","com.azure.messaging.webpubsub.chat.models.ChatTopic":"WebPubSubChat.ChatTopic","com.azure.messaging.webpubsub.chat.models.ChatTopicState":"WebPubSubChat.ChatTopicState","com.azure.messaging.webpubsub.chat.models.ChatUser":"WebPubSubChat.ChatUser","com.azure.messaging.webpubsub.chat.models.ChatUserKind":"WebPubSubChat.ChatUserKind","com.azure.messaging.webpubsub.chat.models.ChatUserRoom":"WebPubSubChat.ChatUserRoom","com.azure.messaging.webpubsub.chat.models.HumanChatUser":"WebPubSubChat.HumanChatUser","com.azure.messaging.webpubsub.chat.models.MessageContent":"WebPubSubChat.MessageContent"},"generatedFiles":["src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceAsyncClient.java","src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceClient.java","src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceClientBuilder.java","src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceVersion.java","src/main/java/com/azure/messaging/webpubsub/chat/implementation/JsonMergePatchHelper.java","src/main/java/com/azure/messaging/webpubsub/chat/implementation/WebPubSubChatServiceClientImpl.java","src/main/java/com/azure/messaging/webpubsub/chat/implementation/models/GenerateClientTokenResponse.java","src/main/java/com/azure/messaging/webpubsub/chat/implementation/models/package-info.java","src/main/java/com/azure/messaging/webpubsub/chat/implementation/package-info.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatConversation.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatMessage.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatPermission.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatRole.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatRoom.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatRoomMember.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatTopic.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatTopicState.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatUser.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatUserKind.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatUserRoom.java","src/main/java/com/azure/messaging/webpubsub/chat/models/HumanChatUser.java","src/main/java/com/azure/messaging/webpubsub/chat/models/MessageContent.java","src/main/java/com/azure/messaging/webpubsub/chat/models/package-info.java","src/main/java/com/azure/messaging/webpubsub/chat/package-info.java","src/main/java/module-info.java"]} \ No newline at end of file +{"flavor":"azure","apiVersions":{"WebPubSubChat":"2026-08-01-preview"},"crossLanguagePackageId":"WebPubSubChat","crossLanguageVersion":"c47dbe5e13af","crossLanguageDefinitions":{"com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient":"Customizations.WebPubSubChatServiceClient","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceRole":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceRoleWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceRoom":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceRoomMember":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoomMember","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceRoomMemberWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoomMember","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceRoomWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceTopic":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceTopicWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceUser":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceUserWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteMessage":"WebPubSubChat.WebPubSubChatServiceClient.deleteMessage","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteMessageWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteMessage","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteRole":"WebPubSubChat.WebPubSubChatServiceClient.deleteRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteRoleWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteRoom":"WebPubSubChat.WebPubSubChatServiceClient.deleteRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteRoomMember":"WebPubSubChat.WebPubSubChatServiceClient.deleteRoomMember","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteRoomMemberWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteRoomMember","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteRoomWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteTopic":"WebPubSubChat.WebPubSubChatServiceClient.deleteTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteTopicWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteUser":"WebPubSubChat.WebPubSubChatServiceClient.deleteUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteUserWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.generateClientToken":"Customizations.WebPubSubChatServiceClient.generateClientToken","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.generateClientTokenWithResponse":"Customizations.WebPubSubChatServiceClient.generateClientToken","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getConversation":"WebPubSubChat.WebPubSubChatServiceClient.getConversation","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getConversationWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getConversation","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getRole":"WebPubSubChat.WebPubSubChatServiceClient.getRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getRoleWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getRoom":"WebPubSubChat.WebPubSubChatServiceClient.getRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getRoomWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getTopic":"WebPubSubChat.WebPubSubChatServiceClient.getTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getTopicWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getUser":"WebPubSubChat.WebPubSubChatServiceClient.getUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getUserWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.listMessages":"WebPubSubChat.WebPubSubChatServiceClient.listMessages","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.listRoles":"WebPubSubChat.WebPubSubChatServiceClient.listRoles","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.listRoomMembers":"WebPubSubChat.WebPubSubChatServiceClient.listRoomMembers","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.listRooms":"WebPubSubChat.WebPubSubChatServiceClient.listRooms","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.listRoomsForUser":"WebPubSubChat.WebPubSubChatServiceClient.listRoomsForUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.listTopics":"WebPubSubChat.WebPubSubChatServiceClient.listTopics","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.listUsers":"WebPubSubChat.WebPubSubChatServiceClient.listUsers","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.updateMessage":"WebPubSubChat.WebPubSubChatServiceClient.updateMessage","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.updateMessageWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.updateMessage","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.updateTopic":"WebPubSubChat.WebPubSubChatServiceClient.updateTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.updateTopicWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.updateTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient":"Customizations.WebPubSubChatServiceClient","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceRole":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceRoleWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceRoom":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceRoomMember":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoomMember","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceRoomMemberWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoomMember","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceRoomWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceTopic":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceTopicWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceUser":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceUserWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteMessage":"WebPubSubChat.WebPubSubChatServiceClient.deleteMessage","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteMessageWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteMessage","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteRole":"WebPubSubChat.WebPubSubChatServiceClient.deleteRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteRoleWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteRoom":"WebPubSubChat.WebPubSubChatServiceClient.deleteRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteRoomMember":"WebPubSubChat.WebPubSubChatServiceClient.deleteRoomMember","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteRoomMemberWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteRoomMember","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteRoomWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteTopic":"WebPubSubChat.WebPubSubChatServiceClient.deleteTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteTopicWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteUser":"WebPubSubChat.WebPubSubChatServiceClient.deleteUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteUserWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.generateClientToken":"Customizations.WebPubSubChatServiceClient.generateClientToken","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.generateClientTokenWithResponse":"Customizations.WebPubSubChatServiceClient.generateClientToken","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getConversation":"WebPubSubChat.WebPubSubChatServiceClient.getConversation","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getConversationWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getConversation","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getRole":"WebPubSubChat.WebPubSubChatServiceClient.getRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getRoleWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getRoom":"WebPubSubChat.WebPubSubChatServiceClient.getRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getRoomWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getTopic":"WebPubSubChat.WebPubSubChatServiceClient.getTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getTopicWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getUser":"WebPubSubChat.WebPubSubChatServiceClient.getUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getUserWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.listMessages":"WebPubSubChat.WebPubSubChatServiceClient.listMessages","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.listRoles":"WebPubSubChat.WebPubSubChatServiceClient.listRoles","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.listRoomMembers":"WebPubSubChat.WebPubSubChatServiceClient.listRoomMembers","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.listRooms":"WebPubSubChat.WebPubSubChatServiceClient.listRooms","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.listRoomsForUser":"WebPubSubChat.WebPubSubChatServiceClient.listRoomsForUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.listTopics":"WebPubSubChat.WebPubSubChatServiceClient.listTopics","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.listUsers":"WebPubSubChat.WebPubSubChatServiceClient.listUsers","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.updateMessage":"WebPubSubChat.WebPubSubChatServiceClient.updateMessage","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.updateMessageWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.updateMessage","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.updateTopic":"WebPubSubChat.WebPubSubChatServiceClient.updateTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.updateTopicWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.updateTopic","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClientBuilder":"Customizations.WebPubSubChatServiceClient","com.azure.messaging.webpubsub.chat.implementation.models.GenerateClientTokenResponse":"Customizations.GenerateClientTokenResponse","com.azure.messaging.webpubsub.chat.models.ChatConversation":"WebPubSubChat.ChatConversation","com.azure.messaging.webpubsub.chat.models.ChatMessage":"WebPubSubChat.ChatMessage","com.azure.messaging.webpubsub.chat.models.ChatPermission":"WebPubSubChat.ChatPermission","com.azure.messaging.webpubsub.chat.models.ChatRole":"WebPubSubChat.ChatRole","com.azure.messaging.webpubsub.chat.models.ChatRoom":"WebPubSubChat.ChatRoom","com.azure.messaging.webpubsub.chat.models.ChatRoomMember":"WebPubSubChat.ChatRoomMember","com.azure.messaging.webpubsub.chat.models.ChatTopic":"WebPubSubChat.ChatTopic","com.azure.messaging.webpubsub.chat.models.ChatTopicState":"WebPubSubChat.ChatTopicState","com.azure.messaging.webpubsub.chat.models.ChatUser":"WebPubSubChat.ChatUser","com.azure.messaging.webpubsub.chat.models.ChatUserKind":"WebPubSubChat.ChatUserKind","com.azure.messaging.webpubsub.chat.models.ChatUserRoom":"WebPubSubChat.ChatUserRoom","com.azure.messaging.webpubsub.chat.models.HumanChatUser":"WebPubSubChat.HumanChatUser","com.azure.messaging.webpubsub.chat.models.MessageContent":"WebPubSubChat.MessageContent"},"generatedFiles":["src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceAsyncClient.java","src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceClient.java","src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceClientBuilder.java","src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceVersion.java","src/main/java/com/azure/messaging/webpubsub/chat/implementation/JsonMergePatchHelper.java","src/main/java/com/azure/messaging/webpubsub/chat/implementation/WebPubSubChatServiceClientImpl.java","src/main/java/com/azure/messaging/webpubsub/chat/implementation/models/GenerateClientTokenResponse.java","src/main/java/com/azure/messaging/webpubsub/chat/implementation/models/package-info.java","src/main/java/com/azure/messaging/webpubsub/chat/implementation/package-info.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatConversation.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatMessage.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatPermission.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatRole.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatRoom.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatRoomMember.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatTopic.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatTopicState.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatUser.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatUserKind.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatUserRoom.java","src/main/java/com/azure/messaging/webpubsub/chat/models/HumanChatUser.java","src/main/java/com/azure/messaging/webpubsub/chat/models/MessageContent.java","src/main/java/com/azure/messaging/webpubsub/chat/models/package-info.java","src/main/java/com/azure/messaging/webpubsub/chat/package-info.java","src/main/java/module-info.java"]} \ No newline at end of file diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/tsp-location.yaml b/sdk/webpubsub/azure-messaging-webpubsub-chat/tsp-location.yaml index dbfdb1f549527..0a6816954dbf5 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/tsp-location.yaml +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/tsp-location.yaml @@ -1,4 +1,4 @@ directory: specification/webpubsub/data-plane/WebPubSubChat -commit: cac305c7810afd20b8cfa009852d4fb0975c528a +commit: 9284694f06a48f38a4b2a46f14ecee7820750132 repo: Azure/azure-rest-api-specs additionalDirectories: From 7244aa370fb350e544725ed8e1b210fcd25062d7 Mon Sep 17 00:00:00 2001 From: Zitong Yang Date: Thu, 29 Oct 2026 22:55:57 +1100 Subject: [PATCH 16/18] Restore generated Chat client builder methods Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .../src/main/java/WebPubSubChatCustomization.java | 8 ++++++++ .../webpubsub/chat/WebPubSubChatServiceClientBuilder.java | 2 ++ 2 files changed, 10 insertions(+) diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/src/main/java/WebPubSubChatCustomization.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/src/main/java/WebPubSubChatCustomization.java index 002a285cf4620..324bd4870a945 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/src/main/java/WebPubSubChatCustomization.java +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/src/main/java/WebPubSubChatCustomization.java @@ -30,6 +30,14 @@ public void customize(LibraryCustomization libraryCustomization, Logger logger) .noneMatch(type -> type.getNameAsString().equals("ConnectionStringTrait"))) { builder.addImplementedType("ConnectionStringTrait"); } + for (String methodName : new String[] { "buildClient", "buildAsyncClient" }) { + MethodDeclaration method = builder.getMethodsByName(methodName) + .stream() + .findFirst() + .orElseThrow(() -> new IllegalStateException("Missing builder method: " + methodName)); + method.setBody(StaticJavaParser.parseBlock( + "{ return new " + method.getTypeAsString() + "(buildInnerClient(), keyCredential); }")); + } }); }); diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceClientBuilder.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceClientBuilder.java index bdb6fe0e13f49..c6b0377e77200 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceClientBuilder.java +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceClientBuilder.java @@ -353,6 +353,7 @@ private HttpPipeline createHttpPipeline() { * * @return an instance of WebPubSubChatServiceAsyncClient. */ + @Generated public WebPubSubChatServiceAsyncClient buildAsyncClient() { return new WebPubSubChatServiceAsyncClient(buildInnerClient(), keyCredential); } @@ -362,6 +363,7 @@ public WebPubSubChatServiceAsyncClient buildAsyncClient() { * * @return an instance of WebPubSubChatServiceClient. */ + @Generated public WebPubSubChatServiceClient buildClient() { return new WebPubSubChatServiceClient(buildInnerClient(), keyCredential); } From a58e9a8871325a8e5db6aebe73cdb15cf883ea76 Mon Sep 17 00:00:00 2001 From: Zitong Yang Date: Fri, 30 Oct 2026 02:03:56 +1100 Subject: [PATCH 17/18] Diagnose Chat SDK regeneration drift in CI Temporarily print the exact regeneration diff to diagnose the reproducible CI-only failure. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- eng/scripts/Compare-CurrentToCodegeneration.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/eng/scripts/Compare-CurrentToCodegeneration.ps1 b/eng/scripts/Compare-CurrentToCodegeneration.ps1 index d354d6845831f..4b97cd90e98bc 100644 --- a/eng/scripts/Compare-CurrentToCodegeneration.ps1 +++ b/eng/scripts/Compare-CurrentToCodegeneration.ps1 @@ -186,6 +186,7 @@ $generateScript = { if ($LastExitCode -ne 0) { $status = (git status -s "$directory" | Out-String) Write-Host "$separatorBar`nThe following TypeSpec files in directoy $directory are out of date`n$status`n$separatorBar" + Write-Host ((& git -c core.safecrlf=false diff --ignore-space-at-eol -- "$directory/*.java" ":(exclude)**/src/test/**" ":(exclude)**/src/samples/**") | Out-String) throw } else { Write-Host "$separatorBar`nSuccessfully ran TypeSpec update in directory with no diff $directory`n$separatorBar" From 4689a8e2975c26fadcaa6718b03d98a3fb19ff3c Mon Sep 17 00:00:00 2001 From: Zitong Yang Date: Fri, 30 Oct 2026 08:00:07 +1100 Subject: [PATCH 18/18] Stabilize Topic state response schema documentation Keep the read-required Topic state documentation consistent when the emitter marks the non-create property optional. Preserve optional request state and remove temporary CI diff diagnostics. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- eng/scripts/Compare-CurrentToCodegeneration.ps1 | 1 - .../src/main/java/WebPubSubChatCustomization.java | 6 +++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/eng/scripts/Compare-CurrentToCodegeneration.ps1 b/eng/scripts/Compare-CurrentToCodegeneration.ps1 index 4b97cd90e98bc..d354d6845831f 100644 --- a/eng/scripts/Compare-CurrentToCodegeneration.ps1 +++ b/eng/scripts/Compare-CurrentToCodegeneration.ps1 @@ -186,7 +186,6 @@ $generateScript = { if ($LastExitCode -ne 0) { $status = (git status -s "$directory" | Out-String) Write-Host "$separatorBar`nThe following TypeSpec files in directoy $directory are out of date`n$status`n$separatorBar" - Write-Host ((& git -c core.safecrlf=false diff --ignore-space-at-eol -- "$directory/*.java" ":(exclude)**/src/test/**" ":(exclude)**/src/samples/**") | Out-String) throw } else { Write-Host "$separatorBar`nSuccessfully ran TypeSpec update in directory with no diff $directory`n$separatorBar" diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/src/main/java/WebPubSubChatCustomization.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/src/main/java/WebPubSubChatCustomization.java index 324bd4870a945..c8e3f9c4c5785 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/src/main/java/WebPubSubChatCustomization.java +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/src/main/java/WebPubSubChatCustomization.java @@ -73,8 +73,12 @@ static String correctLifecycleDocumentation(String source) { String responseHeading = "

Response Body Schema

"; int responseStart = corrected.indexOf(responseHeading); if (responseStart >= 0) { + // Topic state is required on read even though it isn't accepted on create. corrected = corrected.substring(0, responseStart) - + corrected.substring(responseStart).replace("(Optional, Required on create)", "(Required)"); + + corrected.substring(responseStart) + .replace("(Optional, Required on create)", "(Required)") + .replace("state: String(Normal/Archived/SoftDeleted) (Optional)", + "state: String(Normal/Archived/SoftDeleted) (Required)"); } int requestStart = corrected.indexOf("

Request Body Schema

"); if (requestStart >= 0) {