diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/CHANGELOG.md b/sdk/webpubsub/azure-messaging-webpubsub-chat/CHANGELOG.md index 00a35e8be44c9..e179f4dfee96a 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/CHANGELOG.md +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/CHANGELOG.md @@ -4,12 +4,29 @@ ### 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 +- 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 +- 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 +- 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. + ## 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/README.md b/sdk/webpubsub/azure-messaging-webpubsub-chat/README.md index 3ffe57c22a48a..6f645427ae2dc 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,19 @@ 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 [//]: # ({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. @@ -74,13 +76,9 @@ For more information, see [Authenticate Azure-hosted Java applications][azure_id ## 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. @@ -92,7 +90,7 @@ 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 @@ -100,28 +98,53 @@ A room groups users together and is the primary organizational unit for chat int ### 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 +- [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 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 @@ -131,47 +154,154 @@ 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. -```java readme-sample-manageChatRoles +### Create a custom role + +```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. -```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 user +```java readme-sample-createChatUser +client.createOrReplaceUser("alice", new HumanChatUser("Alice", BuiltInChatRoles.USER_NORMAL)); +``` + +### 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 + +```java readme-sample-listChatRooms +client.listRooms().forEach(room -> System.out.printf("%s: %s%n", room.getId(), room.getTitle())); +``` + +### List users -client.deleteRoom(room.getId()); -client.deleteUser("alice"); -client.deleteRole("room.contributor"); -client.deleteRole("user.room_creator"); +```java readme-sample-listChatUsers +client.listUsers().forEach(user -> System.out.printf("%s: %s%n", user.getId(), user.getNickname())); ``` -Delete dependent resources in reverse order when they are no longer needed: room, user, and then roles. +### 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(); +``` + +When creating a topic, leave `state` unset (as above) or set it to +`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; +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. + +### 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 @@ -179,13 +309,26 @@ WebPubSubChatServiceAsyncClient asyncClient = new WebPubSubChatServiceClientBuil .connectionString("") .hub("chat") .buildAsyncClient(); +``` + +Subscribe to the returned publisher to execute an asynchronous operation, and +handle errors explicitly: -asyncClient.listRoles().subscribe(role -> System.out.println(role.getName())); +```java readme-sample-listChatTopicsAsync +asyncClient.listTopics("general").subscribe( + topic -> System.out.println(topic.getTitle()), + error -> System.err.println("Could not list topics: " + error.getMessage())); ``` -### Service API versions +#### Asynchronous paging + +Use `byPage(pageSize)` on typed asynchronous collections to request a page size: -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. +```java readme-sample-listChatTopicsAsyncByPage +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())); +``` ## Troubleshooting @@ -197,12 +340,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 @@ -210,6 +347,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. @@ -218,7 +357,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 @@ -244,7 +383,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/ diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/assets.json b/sdk/webpubsub/azure-messaging-webpubsub-chat/assets.json index 946f2266fe205..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_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_56e475133e"} \ No newline at end of file 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 83e9d0168a860..0000000000000 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/customization.md +++ /dev/null @@ -1,372 +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. - -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/pom.xml b/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/pom.xml index edc4a0ba3e77f..ed513dc4792e2 100644 --- a/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/pom.xml +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/customization/pom.xml @@ -22,4 +22,5 @@ ../../../../ + \ 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..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 @@ -4,6 +4,10 @@ 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 com.github.javaparser.ast.CompilationUnit; +import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; import org.slf4j.Logger; /** Customizes the generated Azure Web PubSub Chat client library. */ @@ -26,15 +30,124 @@ 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); }")); + } }); }); customizeTokenClient(chatPackage, "WebPubSubChatServiceClient"); customizeTokenClient(chatPackage, "WebPubSubChatServiceAsyncClient"); + libraryCustomization.getPackage(PACKAGE_NAME + ".models") + .getClass("MessageContent") + .customizeAst(WebPubSubChatCustomization::customizeMessageContent); + 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" }) { + 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) { + // 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)") + .replace("state: String(Normal/Archived/SoftDeleted) (Optional)", + "state: String(Normal/Archived/SoftDeleted) (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().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); + } + } + return 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() + .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"); + 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("updatedProperties").ifPresent(field -> field.remove()); + model.getMethodsByName("setText").forEach(method -> method.remove()); + model.getMethodsByName("setBinary").forEach(method -> method.remove()); + model.getMethodsByName("toJsonMergePatch").forEach(method -> method.remove()); + } + private static void customizeTokenClient(PackageCustomization chatPackage, String className) { chatPackage.getClass(className).customizeAst(ast -> { ast.getImports() 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..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 @@ -28,8 +28,10 @@ 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.GetClientAccessTokenOptions; +import com.azure.messaging.webpubsub.chat.models.ChatUserRoom; +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; @@ -85,6 +87,9 @@ public Mono> getConversationWithResponse(String conversatio /** * 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

* * @@ -101,8 +106,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) * } @@ -172,14 +177,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)
      * }
      * }
      * 
@@ -190,8 +192,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) * } @@ -210,7 +212,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. @@ -221,8 +223,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); } /** @@ -309,11 +311,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)
      * }
      * }
      * 
@@ -340,7 +340,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. @@ -353,9 +353,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); } /** @@ -404,10 +404,7 @@ public Mono> deleteRoleWithResponse(String roleName, RequestOptio *
      * {@code
      * {
-     *     id: String (Required)
      *     title: String (Required)
-     *     defaultConversation: String (Required)
-     *     etag: String (Required)
      * }
      * }
      * 
@@ -433,7 +430,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. @@ -443,9 +440,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); } /** @@ -557,9 +554,7 @@ public PagedFlux listRoomMembers(String roomId, RequestOptions reque *
      * {@code
      * {
-     *     userId: String (Required)
      *     roleName: String (Required)
-     *     etag: String (Required)
      * }
      * }
      * 
@@ -585,7 +580,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. @@ -596,8 +591,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); } /** @@ -684,9 +679,7 @@ public Mono> getUserWithResponse(String userId, RequestOpti * {@code * { * kind: String(Human) (Required) - * id: String (Required) * nickname: String (Required) - * etag: String (Required) * } * } * @@ -712,7 +705,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. @@ -723,9 +716,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); } /** @@ -779,6 +772,9 @@ public Mono getConversation(String conversationId) { /** * 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. @@ -827,6 +823,9 @@ public PagedFlux listMessages(String conversationId, String latestM /** * 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. @@ -919,7 +918,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. @@ -931,7 +930,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(); @@ -943,12 +942,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)); } @@ -958,7 +957,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. @@ -969,15 +968,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)); } @@ -1086,7 +1085,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. @@ -1101,7 +1100,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(); @@ -1112,7 +1111,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)); } @@ -1121,7 +1120,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. @@ -1135,10 +1134,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)); } @@ -1198,7 +1197,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. @@ -1210,7 +1209,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(); @@ -1221,7 +1220,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)); } @@ -1232,7 +1231,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. @@ -1243,10 +1242,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)); } @@ -1408,7 +1407,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. @@ -1420,7 +1419,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(); @@ -1432,7 +1431,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)); } @@ -1442,7 +1441,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. @@ -1453,10 +1452,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)); } @@ -1545,7 +1544,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. @@ -1557,7 +1556,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(); @@ -1568,7 +1567,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)); } @@ -1580,7 +1579,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. @@ -1591,10 +1590,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)); } @@ -1653,11 +1652,883 @@ 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); } + + /** + * 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 (Required)
+     *     createdAt: OffsetDateTime (Required)
+     *     createdBy: String (Required)
+     *     state: String(Normal/Archived/SoftDeleted) (Required)
+     *     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. + * + *

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

+ * + * + * + * + * + *
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
+     * {
+     *     title: String (Required)
+     *     state: String(Normal/Archived/SoftDeleted) (Optional)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     title: String (Required)
+     *     createdAt: OffsetDateTime (Required)
+     *     createdBy: String (Required)
+     *     state: String(Normal/Archived/SoftDeleted) (Required)
+     *     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 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. + * @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 topic, + RequestOptions requestOptions) { + return this.serviceClient.createOrReplaceTopicWithResponseAsync(roomId, topicId, topic, requestOptions); + } + + /** + * Get topic information. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     title: String (Required)
+     *     createdAt: OffsetDateTime (Required)
+     *     createdBy: String (Required)
+     *     state: String(Normal/Archived/SoftDeleted) (Required)
+     *     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
+     * {
+     *     title: String (Optional)
+     *     state: String(Normal/Archived/SoftDeleted) (Optional)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     title: String (Required)
+     *     createdAt: OffsetDateTime (Required)
+     *     createdBy: String (Required)
+     *     state: String(Normal/Archived/SoftDeleted) (Required)
+     *     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 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. + * @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 topic, + RequestOptions requestOptions) { + return this.serviceClient.updateTopicWithResponseAsync(roomId, topicId, topic, 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; + 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() + .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; + 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() + .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; + 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() + .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; + 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() + .stream() + .map(protocolMethodData -> protocolMethodData.toObject(ChatTopic.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), null)); + }); + } + + /** + * 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. + * @param topicId Topic identifier unique within the room. + * @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. + * @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 topic, + 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(topic), requestOptions) + .flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(ChatTopic.class)); + } + + /** + * 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. + * @param topicId Topic identifier unique within the room. + * @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. + * @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 topic) { + // Generated convenience method for createOrReplaceTopicWithResponse + RequestOptions requestOptions = new RequestOptions(); + return createOrReplaceTopicWithResponse(roomId, topicId, BinaryData.fromObject(topic), 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 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. + * @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 topic, + 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(topic, true); + BinaryData topicInBinaryData = BinaryData.fromObject(topic); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + topicInBinaryData.getLength(); + JsonMergePatchHelper.getChatTopicAccessor().prepareModelForJsonMergePatch(topic, false); + return updateTopicWithResponse(roomId, topicId, topicInBinaryData, 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 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. + * @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 topic) { + // Generated convenience method for updateTopicWithResponse + RequestOptions requestOptions = new RequestOptions(); + JsonMergePatchHelper.getChatTopicAccessor().prepareModelForJsonMergePatch(topic, true); + BinaryData topicInBinaryData = BinaryData.fromObject(topic); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + topicInBinaryData.getLength(); + JsonMergePatchHelper.getChatTopicAccessor().prepareModelForJsonMergePatch(topic, false); + return updateTopicWithResponse(roomId, topicId, topicInBinaryData, 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; + 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() + .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; + 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() + .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; + 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() + .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; + 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() + .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..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 @@ -25,8 +25,10 @@ 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.GetClientAccessTokenOptions; +import com.azure.messaging.webpubsub.chat.models.ChatUserRoom; +import com.azure.messaging.webpubsub.chat.models.ClientAccessTokenOptions; import com.azure.messaging.webpubsub.chat.models.WebPubSubClientAccessToken; /** @@ -78,6 +80,9 @@ public Response getConversationWithResponse(String conversationId, R /** * 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

* * @@ -94,8 +99,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) * } @@ -165,14 +170,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)
      * }
      * }
      * 
@@ -183,8 +185,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) * } @@ -203,7 +205,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. @@ -213,9 +215,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); } /** @@ -302,11 +304,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)
      * }
      * }
      * 
@@ -333,7 +333,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. @@ -345,9 +345,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); } /** @@ -396,10 +396,7 @@ public Response deleteRoleWithResponse(String roleName, RequestOptions req *
      * {@code
      * {
-     *     id: String (Required)
      *     title: String (Required)
-     *     defaultConversation: String (Required)
-     *     etag: String (Required)
      * }
      * }
      * 
@@ -425,7 +422,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. @@ -435,9 +432,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); } /** @@ -549,9 +546,7 @@ public PagedIterable listRoomMembers(String roomId, RequestOptions r *
      * {@code
      * {
-     *     userId: String (Required)
      *     roleName: String (Required)
-     *     etag: String (Required)
      * }
      * }
      * 
@@ -577,7 +572,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. @@ -587,9 +582,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); } /** @@ -675,9 +670,7 @@ public Response getUserWithResponse(String userId, RequestOptions re * {@code * { * kind: String(Human) (Required) - * id: String (Required) * nickname: String (Required) - * etag: String (Required) * } * } * @@ -703,7 +696,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. @@ -713,9 +706,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); } /** @@ -768,6 +761,9 @@ public ChatConversation getConversation(String conversationId) { /** * 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. @@ -798,6 +794,9 @@ public PagedIterable listMessages(String conversationId, String lat /** * 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. @@ -870,7 +869,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. @@ -882,7 +881,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(); @@ -894,12 +893,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); } @@ -908,7 +907,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. @@ -919,15 +918,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); } @@ -996,7 +995,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. @@ -1010,7 +1009,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(); @@ -1021,7 +1020,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); } @@ -1029,7 +1028,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. @@ -1042,10 +1041,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); } @@ -1102,7 +1101,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. @@ -1114,7 +1113,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(); @@ -1125,7 +1124,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); } @@ -1135,7 +1134,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. @@ -1146,10 +1145,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); } @@ -1271,7 +1270,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. @@ -1283,7 +1282,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(); @@ -1295,7 +1294,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); } @@ -1305,7 +1304,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. @@ -1316,10 +1315,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); } @@ -1405,7 +1404,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. @@ -1417,7 +1416,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(); @@ -1428,7 +1427,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); } @@ -1439,7 +1438,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. @@ -1450,10 +1449,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); } @@ -1509,11 +1508,730 @@ 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); } + + /** + * 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 (Required)
+     *     createdAt: OffsetDateTime (Required)
+     *     createdBy: String (Required)
+     *     state: String(Normal/Archived/SoftDeleted) (Required)
+     *     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. + * + *

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

+ * + * + * + * + * + *
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
+     * {
+     *     title: String (Required)
+     *     state: String(Normal/Archived/SoftDeleted) (Optional)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     title: String (Required)
+     *     createdAt: OffsetDateTime (Required)
+     *     createdBy: String (Required)
+     *     state: String(Normal/Archived/SoftDeleted) (Required)
+     *     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 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. + * @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 topic, + RequestOptions requestOptions) { + return this.serviceClient.createOrReplaceTopicWithResponse(roomId, topicId, topic, requestOptions); + } + + /** + * Get topic information. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     title: String (Required)
+     *     createdAt: OffsetDateTime (Required)
+     *     createdBy: String (Required)
+     *     state: String(Normal/Archived/SoftDeleted) (Required)
+     *     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
+     * {
+     *     title: String (Optional)
+     *     state: String(Normal/Archived/SoftDeleted) (Optional)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     title: String (Required)
+     *     createdAt: OffsetDateTime (Required)
+     *     createdBy: String (Required)
+     *     state: String(Normal/Archived/SoftDeleted) (Required)
+     *     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 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. + * @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 topic, + RequestOptions requestOptions) { + return this.serviceClient.updateTopicWithResponse(roomId, topicId, topic, 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. + * + *

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. + * @param topicId Topic identifier unique within the room. + * @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. + * @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 topic, + 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(topic), requestOptions) + .getValue() + .toObject(ChatTopic.class); + } + + /** + * 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. + * @param topicId Topic identifier unique within the room. + * @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. + * @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 topic) { + // Generated convenience method for createOrReplaceTopicWithResponse + RequestOptions requestOptions = new RequestOptions(); + return createOrReplaceTopicWithResponse(roomId, topicId, BinaryData.fromObject(topic), 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 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. + * @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 topic, 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(topic, true); + BinaryData topicInBinaryData = BinaryData.fromObject(topic); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + topicInBinaryData.getLength(); + JsonMergePatchHelper.getChatTopicAccessor().prepareModelForJsonMergePatch(topic, false); + return updateTopicWithResponse(roomId, topicId, topicInBinaryData, requestOptions).getValue() + .toObject(ChatTopic.class); + } + + /** + * Update a topic. + * + * @param roomId Room identifier. + * @param topicId Topic identifier unique within the room. + * @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. + * @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 topic) { + // Generated convenience method for updateTopicWithResponse + RequestOptions requestOptions = new RequestOptions(); + JsonMergePatchHelper.getChatTopicAccessor().prepareModelForJsonMergePatch(topic, true); + BinaryData topicInBinaryData = BinaryData.fromObject(topic); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + topicInBinaryData.getLength(); + JsonMergePatchHelper.getChatTopicAccessor().prepareModelForJsonMergePatch(topic, false); + return updateTopicWithResponse(roomId, topicId, topicInBinaryData, 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/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); } 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/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/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..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 @@ -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}") @@ -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 }) @@ -370,7 +390,7 @@ Response deleteRoleSync(@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}") @@ -382,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}") @@ -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 topic, 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 topic, 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 topic, 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 topic, 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 }) @@ -459,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 }) @@ -471,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 }) @@ -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 }) @@ -526,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}") @@ -538,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}") @@ -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); } /** @@ -703,6 +961,9 @@ public Response getConversationWithResponse(String conversationId, R /** * 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

* * @@ -719,8 +980,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) * } @@ -752,6 +1013,9 @@ private Mono> listMessagesSinglePageAsync(String conve /** * 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
* @@ -768,8 +1032,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) * } @@ -818,6 +1082,9 @@ public PagedFlux listMessagesAsync(String conversationId, RequestOpt /** * 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
* @@ -834,8 +1101,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) * } @@ -864,6 +1131,9 @@ private PagedResponse listMessagesSinglePage(String conversationId, /** * 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
* @@ -880,8 +1150,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) * } @@ -1003,14 +1273,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)
      * }
      * }
      * 
@@ -1021,8 +1288,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) * } @@ -1041,7 +1308,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. @@ -1051,12 +1318,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)); } /** @@ -1076,14 +1343,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)
      * }
      * }
      * 
@@ -1094,8 +1358,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) * } @@ -1114,7 +1378,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. @@ -1123,12 +1387,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); } /** @@ -1412,11 +1676,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)
      * }
      * }
      * 
@@ -1443,7 +1705,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. @@ -1455,13 +1717,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)); } /** @@ -1481,11 +1743,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)
      * }
      * }
      * 
@@ -1512,7 +1772,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. @@ -1523,12 +1783,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); } /** @@ -1586,32 +1846,15 @@ 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

- * - *
-     * {@code
-     * {
-     *     id: String (Required)
-     *     title: String (Required)
-     *     defaultConversation: String (Required)
-     *     etag: String (Required)
-     * }
-     * }
-     * 
- * + * You can add these to a request with {@link RequestOptions#addQueryParam} *

Response Body Schema

* *
@@ -1624,16 +1867,228 @@ public Response deleteRoleWithResponse(String roleName, RequestOptions req
      * }
      * }
      * 
- * - *

Response Headers

- * - * - * - * - *
Response Headers
NameTypeDescription
ETagStringThe entity tag for the response.
* - * @param roomId Room identifier. - * @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 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

+ * + *
+     * {@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}. + */ + @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
+     * {
+     *     title: String (Required)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

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

Response Headers

+ * + * + * + * + *
Response Headers
NameTypeDescription
ETagStringThe entity tag for the response.
+ * + * @param roomId Room identifier. + * @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. @@ -1642,13 +2097,13 @@ public Response deleteRoleWithResponse(String roleName, RequestOptions req * @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)); } /** @@ -1670,10 +2125,7 @@ public Mono> createOrReplaceRoomWithResponseAsync(String ro *
      * {@code
      * {
-     *     id: String (Required)
      *     title: String (Required)
-     *     defaultConversation: String (Required)
-     *     etag: String (Required)
      * }
      * }
      * 
@@ -1699,7 +2151,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. @@ -1708,12 +2160,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); } /** @@ -1831,7 +2283,7 @@ public Response deleteRoomWithResponse(String roomId, RequestOptions reque } /** - * Get room members. + * List topics in a room with pagination. *

Query Parameters

* * @@ -1845,8 +2297,12 @@ public Response deleteRoomWithResponse(String roomId, RequestOptions reque *
      * {@code
      * {
-     *     userId: String (Required)
-     *     roleName: String (Required)
+     *     id: String (Required)
+     *     title: String (Required)
+     *     createdAt: OffsetDateTime (Required)
+     *     createdBy: String (Required)
+     *     state: String(Normal/Archived/SoftDeleted) (Required)
+     *     conversationId: String (Required)
      *     etag: String (Required)
      * }
      * }
@@ -1858,21 +2314,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 +2342,12 @@ private Mono> listRoomMembersSinglePageAsync(String ro *
      * {@code
      * {
-     *     userId: String (Required)
-     *     roleName: String (Required)
+     *     id: String (Required)
+     *     title: String (Required)
+     *     createdAt: OffsetDateTime (Required)
+     *     createdBy: String (Required)
+     *     state: String(Normal/Archived/SoftDeleted) (Required)
+     *     conversationId: String (Required)
      *     etag: String (Required)
      * }
      * }
@@ -1899,10 +2359,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 +2375,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 +2386,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 +2405,12 @@ public PagedFlux listRoomMembersAsync(String roomId, RequestOptions *
      * {@code
      * {
-     *     userId: String (Required)
-     *     roleName: String (Required)
+     *     id: String (Required)
+     *     title: String (Required)
+     *     createdAt: OffsetDateTime (Required)
+     *     createdBy: String (Required)
+     *     state: String(Normal/Archived/SoftDeleted) (Required)
+     *     conversationId: String (Required)
      *     etag: String (Required)
      * }
      * }
@@ -1958,19 +2422,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 +2448,12 @@ private PagedResponse listRoomMembersSinglePage(String roomId, Reque *
      * {@code
      * {
-     *     userId: String (Required)
-     *     roleName: String (Required)
+     *     id: String (Required)
+     *     title: String (Required)
+     *     createdAt: OffsetDateTime (Required)
+     *     createdBy: String (Required)
+     *     state: String(Normal/Archived/SoftDeleted) (Required)
+     *     conversationId: String (Required)
      *     etag: String (Required)
      * }
      * }
@@ -1997,10 +2465,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 +2481,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 +2492,16 @@ 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.
+     *
+     * 

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

*
Query Parameters
* @@ -2045,9 +2517,8 @@ public PagedIterable listRoomMembers(String roomId, RequestOptions r *
      * {@code
      * {
-     *     userId: String (Required)
-     *     roleName: String (Required)
-     *     etag: String (Required)
+     *     title: String (Required)
+     *     state: String(Normal/Archived/SoftDeleted) (Optional)
      * }
      * }
      * 
@@ -2057,8 +2528,12 @@ public PagedIterable listRoomMembers(String roomId, RequestOptions r *
      * {@code
      * {
-     *     userId: String (Required)
-     *     roleName: String (Required)
+     *     id: String (Required)
+     *     title: String (Required)
+     *     createdAt: OffsetDateTime (Required)
+     *     createdBy: String (Required)
+     *     state: String(Normal/Archived/SoftDeleted) (Required)
+     *     conversationId: String (Required)
      *     etag: String (Required)
      * }
      * }
@@ -2072,27 +2547,31 @@ public PagedIterable listRoomMembers(String roomId, RequestOptions r
      * 
Header Parameters
* * @param roomId Room identifier. - * @param userId User ID of the member. - * @param resource The resource instance. + * @param topicId Topic identifier unique within the room. + * @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. * @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, - BinaryData resource, RequestOptions requestOptions) { + public Mono> createOrReplaceTopicWithResponseAsync(String roomId, String topicId, + BinaryData topic, 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, topic, requestOptions, context)); } /** - * Create or replace a room member. + * 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

* * @@ -2108,9 +2587,8 @@ public Mono> createOrReplaceRoomMemberWithResponseAsync(Str *
      * {@code
      * {
-     *     userId: String (Required)
-     *     roleName: String (Required)
-     *     etag: String (Required)
+     *     title: String (Required)
+     *     state: String(Normal/Archived/SoftDeleted) (Optional)
      * }
      * }
      * 
@@ -2120,8 +2598,12 @@ public Mono> createOrReplaceRoomMemberWithResponseAsync(Str *
      * {@code
      * {
-     *     userId: String (Required)
-     *     roleName: String (Required)
+     *     id: String (Required)
+     *     title: String (Required)
+     *     createdAt: OffsetDateTime (Required)
+     *     createdBy: String (Required)
+     *     state: String(Normal/Archived/SoftDeleted) (Required)
+     *     conversationId: String (Required)
      *     etag: String (Required)
      * }
      * }
@@ -2135,156 +2617,95 @@ public Mono> createOrReplaceRoomMemberWithResponseAsync(Str
      * 
Header Parameters
* * @param roomId Room identifier. - * @param userId User ID of the member. - * @param resource The resource instance. + * @param topicId Topic identifier unique within the room. + * @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. * @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 topic, 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

- * - * - * - * - * - *
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); + return service.createOrReplaceTopicSync(this.getEndpoint(), this.getServiceVersion().getVersion(), + this.getHub(), roomId, topicId, contentType, accept, topic, requestOptions, Context.NONE); } /** - * Get a user's profile. - * - * Get a user's profile. The response is a polymorphic `ChatUser` (e.g. `HumanChatUser`) selected by the `kind` - * discriminator. + * Get topic information. *

Response Body Schema

* *
      * {@code
      * {
-     *     kind: String(Human) (Required)
      *     id: String (Required)
-     *     nickname: String (Required)
+     *     title: String (Required)
+     *     createdAt: OffsetDateTime (Required)
+     *     createdBy: String (Required)
+     *     state: String(Normal/Archived/SoftDeleted) (Required)
+     *     conversationId: String (Required)
      *     etag: String (Required)
      * }
      * }
      * 
* - * @param userId User identifier. + * @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 a user's profile. - * - * Get a user's profile along with {@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> getUserWithResponseAsync(String userId, RequestOptions requestOptions) { + public Mono> getTopicWithResponseAsync(String roomId, String topicId, + RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.getUser(this.getEndpoint(), - this.getServiceVersion().getVersion(), this.getHub(), userId, accept, requestOptions, context)); + return FluxUtil.withContext(context -> service.getTopic(this.getEndpoint(), + this.getServiceVersion().getVersion(), this.getHub(), roomId, topicId, accept, requestOptions, context)); } /** - * Get a user's profile. - * - * Get a user's profile. The response is a polymorphic `ChatUser` (e.g. `HumanChatUser`) selected by the `kind` - * discriminator. + * Get topic information. *

Response Body Schema

* *
      * {@code
      * {
-     *     kind: String(Human) (Required)
      *     id: String (Required)
-     *     nickname: String (Required)
+     *     title: String (Required)
+     *     createdAt: OffsetDateTime (Required)
+     *     createdBy: String (Required)
+     *     state: String(Normal/Archived/SoftDeleted) (Required)
+     *     conversationId: String (Required)
      *     etag: String (Required)
      * }
      * }
      * 
* - * @param userId User identifier. + * @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 a user's profile. - * - * Get a user's profile along with {@link Response}. + * @return topic information along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response getUserWithResponse(String userId, RequestOptions requestOptions) { + public Response getTopicWithResponse(String roomId, String topicId, RequestOptions requestOptions) { final String accept = "application/json"; - return service.getUserSync(this.getEndpoint(), this.getServiceVersion().getVersion(), this.getHub(), userId, - accept, requestOptions, Context.NONE); + return service.getTopicSync(this.getEndpoint(), this.getServiceVersion().getVersion(), this.getHub(), roomId, + topicId, accept, requestOptions, Context.NONE); } /** - * Create or replace a user. - * - * Create or replace a user. The request body is a polymorphic `ChatUser` (e.g. `HumanChatUser`) selected by the - * `kind` discriminator. + * Update a topic. *

Header Parameters

* * @@ -2300,10 +2721,8 @@ public Response getUserWithResponse(String userId, RequestOptions re *
      * {@code
      * {
-     *     kind: String(Human) (Required)
-     *     id: String (Required)
-     *     nickname: String (Required)
-     *     etag: String (Required)
+     *     title: String (Optional)
+     *     state: String(Normal/Archived/SoftDeleted) (Optional)
      * }
      * }
      * 
@@ -2313,9 +2732,12 @@ public Response getUserWithResponse(String userId, RequestOptions re *
      * {@code
      * {
-     *     kind: String(Human) (Required)
      *     id: String (Required)
-     *     nickname: String (Required)
+     *     title: String (Required)
+     *     createdAt: OffsetDateTime (Required)
+     *     createdBy: String (Required)
+     *     state: String(Normal/Archived/SoftDeleted) (Required)
+     *     conversationId: String (Required)
      *     etag: String (Required)
      * }
      * }
@@ -2328,31 +2750,28 @@ public Response getUserWithResponse(String userId, RequestOptions re
      * 
*
Header Parameters
ETagStringThe entity tag for the response.
* - * @param userId User identifier. - * @param resource The resource instance. + * @param roomId Room identifier. + * @param topicId Topic identifier unique within the room. + * @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. * @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 user profile in the chat system 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> createOrReplaceUserWithResponseAsync(String userId, BinaryData resource, + public Mono> updateTopicWithResponseAsync(String roomId, String topicId, BinaryData topic, RequestOptions requestOptions) { - final String contentType = "application/json"; + final String contentType = "application/merge-patch+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)); + return FluxUtil + .withContext(context -> service.updateTopic(this.getEndpoint(), this.getServiceVersion().getVersion(), + this.getHub(), roomId, topicId, contentType, accept, topic, requestOptions, context)); } /** - * Create or replace a user. - * - * Create or replace a user. The request body is a polymorphic `ChatUser` (e.g. `HumanChatUser`) selected by the - * `kind` discriminator. + * Update a topic. *

Header Parameters

* * @@ -2368,10 +2787,8 @@ public Mono> createOrReplaceUserWithResponseAsync(String us *
      * {@code
      * {
-     *     kind: String(Human) (Required)
-     *     id: String (Required)
-     *     nickname: String (Required)
-     *     etag: String (Required)
+     *     title: String (Optional)
+     *     state: String(Normal/Archived/SoftDeleted) (Optional)
      * }
      * }
      * 
@@ -2381,9 +2798,12 @@ public Mono> createOrReplaceUserWithResponseAsync(String us *
      * {@code
      * {
-     *     kind: String(Human) (Required)
      *     id: String (Required)
-     *     nickname: String (Required)
+     *     title: String (Required)
+     *     createdAt: OffsetDateTime (Required)
+     *     createdBy: String (Required)
+     *     state: String(Normal/Archived/SoftDeleted) (Required)
+     *     conversationId: String (Required)
      *     etag: String (Required)
      * }
      * }
@@ -2396,26 +2816,27 @@ public Mono> createOrReplaceUserWithResponseAsync(String us
      * 
*
Header Parameters
ETagStringThe entity tag for the response.
* - * @param userId User identifier. - * @param resource The resource instance. + * @param roomId Room identifier. + * @param topicId Topic identifier unique within the room. + * @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. * @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 user profile in the chat system along with {@link Response}. + * @return represents a chat topic in a room along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response createOrReplaceUserWithResponse(String userId, BinaryData resource, + public Response updateTopicWithResponse(String roomId, String topicId, BinaryData topic, RequestOptions requestOptions) { - final String contentType = "application/json"; + final String contentType = "application/merge-patch+json"; final String accept = "application/json"; - return service.createOrReplaceUserSync(this.getEndpoint(), this.getServiceVersion().getVersion(), this.getHub(), - userId, contentType, accept, resource, requestOptions, Context.NONE); + return service.updateTopicSync(this.getEndpoint(), this.getServiceVersion().getVersion(), this.getHub(), roomId, + topicId, contentType, accept, topic, requestOptions, Context.NONE); } /** - * Delete a user. + * Soft delete a topic. *

Header Parameters

* * @@ -2427,7 +2848,8 @@ public Response createOrReplaceUserWithResponse(String userId, Binar *
Header Parameters
* You can add these to a request with {@link RequestOptions#addHeader} * - * @param userId User identifier. + * @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. @@ -2436,13 +2858,14 @@ public Response createOrReplaceUserWithResponse(String userId, Binar * @return the {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> deleteUserWithResponseAsync(String userId, RequestOptions requestOptions) { - return FluxUtil.withContext(context -> service.deleteUser(this.getEndpoint(), - this.getServiceVersion().getVersion(), this.getHub(), userId, requestOptions, context)); + 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)); } /** - * Delete a user. + * Soft delete a topic. *

Header Parameters

* * @@ -2454,7 +2877,8 @@ public Mono> deleteUserWithResponseAsync(String userId, RequestOp *
Header Parameters
* You can add these to a request with {@link RequestOptions#addHeader} * - * @param userId User identifier. + * @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. @@ -2463,21 +2887,19 @@ public Mono> deleteUserWithResponseAsync(String userId, RequestOp * @return the {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response deleteUserWithResponse(String userId, RequestOptions requestOptions) { - return service.deleteUserSync(this.getEndpoint(), this.getServiceVersion().getVersion(), this.getHub(), userId, - requestOptions, Context.NONE); + public Response deleteTopicWithResponse(String roomId, String topicId, RequestOptions requestOptions) { + return service.deleteTopicSync(this.getEndpoint(), this.getServiceVersion().getVersion(), this.getHub(), roomId, + topicId, requestOptions, Context.NONE); } /** - * Generate a token for connecting a client to Azure Web PubSub. + * Get room members. *

Query Parameters

* * * - * - * - * + * + * *
Query Parameters
NameTypeRequiredDescription
userIdStringNoUser identifier for the client connection.
roleList<String>NoRoles granted to the client connection. Call - * {@link RequestOptions#addQueryParam} to add string to array.
minutesToExpireIntegerNoLifetime of the generated token, in minutes.
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

@@ -2485,38 +2907,40 @@ public Response deleteUserWithResponse(String userId, RequestOptions reque *
      * {@code
      * {
-     *     token: String (Required)
+     *     userId: String (Required)
+     *     roleName: String (Required)
+     *     etag: String (Required)
      * }
      * }
      * 
* - * @param hub Target hub name. + * @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 response containing a Web PubSub client access token along with {@link Response} on successful completion - * of {@link Mono}. + * @return room members along with {@link PagedResponse} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> generateClientTokenWithResponseAsync(String hub, RequestOptions requestOptions) { - final String apiVersion = "2024-12-01"; + private Mono> listRoomMembersSinglePageAsync(String roomId, + RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil.withContext(context -> service.generateClientToken(this.getEndpoint(), hub, apiVersion, accept, - requestOptions, context)); + 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)); } /** - * Generate a token for connecting a client to Azure Web PubSub. + * Get room members. *

Query Parameters

* * * - * - * - * + * + * *
Query Parameters
NameTypeRequiredDescription
userIdStringNoUser identifier for the client connection.
roleList<String>NoRoles granted to the client connection. Call - * {@link RequestOptions#addQueryParam} to add string to array.
minutesToExpireIntegerNoLifetime of the generated token, in minutes.
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

@@ -2524,41 +2948,1072 @@ public Mono> generateClientTokenWithResponseAsync(String hu *
      * {@code
      * {
-     *     token: String (Required)
+     *     userId: String (Required)
+     *     roleName: String (Required)
+     *     etag: String (Required)
      * }
      * }
      * 
* - * @param hub Target hub name. + * @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 response containing a Web PubSub client access token along with {@link Response}. + * @return room members as paginated response with {@link PagedFlux}. */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response generateClientTokenWithResponse(String hub, RequestOptions requestOptions) { - final String apiVersion = "2024-12-01"; - final String accept = "application/json"; - return service.generateClientTokenSync(this.getEndpoint(), hub, apiVersion, accept, requestOptions, - Context.NONE); + @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); + }); } /** - * Query messages in a conversation from latest to earliest. - * - * Get the next page of items. + * 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
      * {
-     *     id: String (Required)
-     *     createdBy: String (Optional, Required on create)
-     *     content (Optional, Required on create): {
-     *         text: String (Optional)
-     *         binary: byte[] (Optional)
+     *     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
+     * {
+     *     roleName: 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 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. + * @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 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, member, 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
+     * {
+     *     roleName: 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 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. + * @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 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, member, 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

+ * + * + * + * + * + *
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

+ * + * + * + * + * + *
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}. + */ + @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); + }); + } + + /** + * Get a user's profile. + * + * Get a user's profile. The response is a polymorphic `ChatUser` (e.g. `HumanChatUser`) selected by the `kind` + * discriminator. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String(Human) (Required)
+     *     id: String (Required)
+     *     nickname: 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 a user's profile. + * + * Get a user's profile along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getUserWithResponseAsync(String userId, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.getUser(this.getEndpoint(), + this.getServiceVersion().getVersion(), this.getHub(), userId, accept, requestOptions, context)); + } + + /** + * Get a user's profile. + * + * Get a user's profile. The response is a polymorphic `ChatUser` (e.g. `HumanChatUser`) selected by the `kind` + * discriminator. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String(Human) (Required)
+     *     id: String (Required)
+     *     nickname: 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 a user's profile. + * + * Get a user's profile along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getUserWithResponse(String userId, RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getUserSync(this.getEndpoint(), this.getServiceVersion().getVersion(), this.getHub(), userId, + accept, requestOptions, Context.NONE); + } + + /** + * Create or replace a user. + * + * Create or replace a user. The request body is a polymorphic `ChatUser` (e.g. `HumanChatUser`) selected by the + * `kind` discriminator. + *

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
+     * {
+     *     kind: String(Human) (Required)
+     *     nickname: String (Required)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String(Human) (Required)
+     *     id: String (Required)
+     *     nickname: String (Required)
+     *     etag: String (Required)
+     * }
+     * }
+     * 
+ * + *

Response Headers

+ * + * + * + * + *
Response Headers
NameTypeDescription
ETagStringThe entity tag for the response.
+ * + * @param userId User identifier. + * @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. + * @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 user profile in the chat system along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + 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, user, requestOptions, context)); + } + + /** + * Create or replace a user. + * + * Create or replace a user. The request body is a polymorphic `ChatUser` (e.g. `HumanChatUser`) selected by the + * `kind` discriminator. + *

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
+     * {
+     *     kind: String(Human) (Required)
+     *     nickname: String (Required)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String(Human) (Required)
+     *     id: String (Required)
+     *     nickname: String (Required)
+     *     etag: String (Required)
+     * }
+     * }
+     * 
+ * + *

Response Headers

+ * + * + * + * + *
Response Headers
NameTypeDescription
ETagStringThe entity tag for the response.
+ * + * @param userId User identifier. + * @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. + * @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 user profile in the chat system along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + 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, user, requestOptions, Context.NONE); + } + + /** + * Delete a user. + *

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 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 the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> deleteUserWithResponseAsync(String userId, RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.deleteUser(this.getEndpoint(), + this.getServiceVersion().getVersion(), this.getHub(), userId, requestOptions, context)); + } + + /** + * Delete a user. + *

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 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 the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response deleteUserWithResponse(String userId, RequestOptions requestOptions) { + return service.deleteUserSync(this.getEndpoint(), this.getServiceVersion().getVersion(), this.getHub(), userId, + 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

+ * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
userIdStringNoUser identifier for the client connection.
roleList<String>NoRoles granted to the client connection. Call + * {@link RequestOptions#addQueryParam} to add string to array.
minutesToExpireIntegerNoLifetime of the generated token, in minutes.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     token: String (Required)
+     * }
+     * }
+     * 
+ * + * @param hub Target hub name. + * @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 response containing a Web PubSub client access token along with {@link Response} on successful completion + * of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> generateClientTokenWithResponseAsync(String hub, RequestOptions requestOptions) { + final String apiVersion = "2024-12-01"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.generateClientToken(this.getEndpoint(), hub, apiVersion, accept, + requestOptions, context)); + } + + /** + * Generate a token for connecting a client to Azure Web PubSub. + *

Query Parameters

+ * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
userIdStringNoUser identifier for the client connection.
roleList<String>NoRoles granted to the client connection. Call + * {@link RequestOptions#addQueryParam} to add string to array.
minutesToExpireIntegerNoLifetime of the generated token, in minutes.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     token: String (Required)
+     * }
+     * }
+     * 
+ * + * @param hub Target hub name. + * @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 response containing a Web PubSub client access token along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response generateClientTokenWithResponse(String hub, RequestOptions requestOptions) { + final String apiVersion = "2024-12-01"; + final String accept = "application/json"; + return service.generateClientTokenSync(this.getEndpoint(), hub, apiVersion, accept, requestOptions, + Context.NONE); + } + + /** + * Query messages in a conversation from latest to earliest. + * + * Get the next page of items. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     createdBy: String (Required)
+     *     content (Required): {
+     *         text: String (Optional)
+     *         binary: byte[] (Optional)
      *     }
      *     createdAt: OffsetDateTime (Required)
      *     etag: String (Required)
@@ -2596,8 +4051,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)
      *     }
@@ -2697,6 +4152,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 (Required)
+     *     createdAt: OffsetDateTime (Required)
+     *     createdBy: String (Required)
+     *     state: String(Normal/Archived/SoftDeleted) (Required)
+     *     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 (Required)
+     *     createdAt: OffsetDateTime (Required)
+     *     createdBy: String (Required)
+     *     state: String(Normal/Archived/SoftDeleted) (Required)
+     *     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 +4368,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/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/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..65801f040c4df --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/ChatTopic.java @@ -0,0 +1,275 @@ +// 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. + *

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. + */ + 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/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 61% 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..9cf14d376f39a 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,25 @@ import java.time.Duration; -/** Options for creating a Web PubSub client access token for Chat. */ -public final class GetClientAccessTokenOptions { +/** + * Options for the {@code getClientAccessToken} operation. + */ +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 +31,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 +43,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 e5ee9ed3fa15e..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 @@ -3,41 +3,35 @@ // 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.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 java.util.HashSet; -import java.util.Set; +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 +57,6 @@ public boolean isJsonMergePatch(MessageContent model) { }); } - /** - * Creates an instance of MessageContent class. - */ - @Generated - public MessageContent() { - } - /** * Get the text property: Text content. * @@ -80,19 +67,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 +77,77 @@ 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. + * Reads text or binary message content from JSON. * - * @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. + * @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/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..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-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":"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/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..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 @@ -7,11 +7,15 @@ 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; -import com.azure.messaging.webpubsub.chat.models.GetClientAccessTokenOptions; +import com.azure.messaging.webpubsub.chat.models.ChatTopic; +import com.azure.messaging.webpubsub.chat.models.ChatTopicState; +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; import java.time.Duration; @@ -19,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 @@ -57,71 +71,166 @@ 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 } - /** 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 + } + + /** Lists typed topics asynchronously with an explicit page size. */ + public void listTopicsAsyncByPage(WebPubSubChatServiceAsyncClient asyncClient) { + // BEGIN: readme-sample-listChatTopicsAsyncByPage + 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 + } + /** 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/ChatServiceAsyncClientLiveTests.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/ChatServiceAsyncClientLiveTests.java deleted file mode 100644 index 1d87b738e8c33..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(new MessageContent().setText(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(new MessageContent().setBinary(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 960bd7a5ef75f..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 @@ -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,116 +15,366 @@ 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.GetClientAccessTokenOptions; +import com.azure.messaging.webpubsub.chat.models.ChatUserRoom; +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; -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 { - @Test + @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))); + } + } + + @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()); + 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(), + () -> 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; @@ -133,47 +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 ClientAccessTokenOptions().setUserId(userId)), + () -> entraAsyncClient.getClientAccessToken(new ClientAccessTokenOptions().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(); + String currentMessageId = messageId; - ChatMessage updatedText - = client.updateMessage(conversationId, messageId, new ChatMessage().setCreatedBy(userId) - .setContent(new MessageContent().setText(messageText + " updated"))); + 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(new MessageContent().setBinary(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))); } } } 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/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..48d64233a984c --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/MessageContentTests.java @@ -0,0 +1,206 @@ +// 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.core.util.BinaryData; +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)); + } + + @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); + } + } + + 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); + } +} 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/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..023ebde785e4b --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/WebPubSubChatPaginationTests.java @@ -0,0 +1,161 @@ +// 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.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); + } + + @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..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 @@ -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; @@ -120,12 +122,15 @@ public void connectionStringRejectsMissingRequiredKeys() { () -> new WebPubSubChatServiceClientBuilder().connectionString("AccessKey=" + FIRST_KEY)); } - @Test - public void reverseProxyPreservesJavaServiceBehavior() throws ParseException { + @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 +142,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/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/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 } } diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/tsp-location.yaml b/sdk/webpubsub/azure-messaging-webpubsub-chat/tsp-location.yaml index c1c137f69eb47..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: 2f561e5f227705bf7985424de42fc5edd67d3dd7 +commit: 9284694f06a48f38a4b2a46f14ecee7820750132 repo: Azure/azure-rest-api-specs additionalDirectories: